亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

POJ - 2366 Sacrament of the sum 二分查找

2019-11-10 16:52:14
字體:
來源:轉載
供稿:網友

Sacrament of the sum

— The Brother of mine, the Head of Monastic Order wants to know tomorrow about the results long-term researches. He wants to see neither more nor less than the Summering Machine! Even moreover, he wants our Machine — only a machine — to demonstrate its comPRehension of the Sacrament of the Sum as deeply as it is possible. He wants our Machine to find two numbers that give the sum equal to the Sacred Number 10 000. — Tsh-sh-sh! This is madness that borders on blasphemy! How can the Machine calculate the Sacred Number? Twenty seven years we work on it, but we’ve could teach it to tell if the sum of two introduced numbers greater or lower than 10 000. Can an ordinary mortal find two numbers that there sum will be equal to 10 000? — But we’ll have to do it with the help of our Machine, even if it is not capable. Otherwise we’ll have… let’s say, big problems, if it is possible to call boiling oil like this. However, I have an idea. Do you remember, last week we’ve entered two numbers -7 and 13 into the Machine, and it answered that their sum is lower than 10 000. I don’t know how to check this, but nothing’s left for us than to believe to the fruit of our work. Let’s enter now a greater number than -7 and start up the Machine again. We’ll do like this again and again until we find a number that being added to 13 will give us 10 000. The only thing we are to do is to prepare an ascending list of numbers. — I don’t believe in this… Let’s start with the sum that is obviously greater than the Sacred Number and we’ll decrease one of the summand. So we have more chances to avoid boilin… big problems.

Haven’t come to an agreement, the Brothers went away to their cells. By next day everyone of them has prepared a list of numbers that, to his opinion, could save them… Can both of the lists save them together? Your program should decide, if it is possible to choose from two lists of integers such two numbers that their sum would be equal to 10 000.

Input

You are given both of these lists one by one. Format of each of these lists is as follows: in the first line of the list the quantity of numbers Ni of the i-th list is written. Further there is an i-th list of numbers each number in its line (Ni lines).The following conditions are satisfied: 1 <= Ni <= 50 000, each element of the lists lays in the range from -32768 to 32767. The first list is ascending and the second one is descending.

Output

You should write “YES” to the standard output if it is possible to choose from the two lists of integers such two numbers that their sum would be equal to 10 000. Otherwise you should write “NO”.

Sample Input

4 -175 19 19 10424 3 8951 -424 -788

Sample Output

YES

Hint

This problem has huge input data,use scanf() instead of cin to read data to avoid time limit exceed.

兩個數列都有序,而且只有兩個數列,直接枚舉一個二分查找另一個就好。

代碼

#include <stdio.h>int A[50000],B[50000];int main(){ int i,j,n1,n2,mid,max,min; scanf("%d",&n1); for(i=0;i<n1;++i){ scanf("%d",&A[i]); } scanf("%d",&n2); for(i=0;i<n2;++i){ scanf("%d",&B[i]); } for(i=0;i<n1;++i){ for(min=0,max=n2-1,mid=(max+min)/2;min<=max;mid=(max+min)/2){ if(A[i]+B[mid]==10000){ printf("YES"); return 0; }else if(A[i]+B[mid]>10000){ min=mid+1; }else{ max=mid-1; } } } printf("NO"); return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
国产精品xxxxx| 性欧美在线看片a免费观看| 国产深夜精品福利| 中文字幕在线日韩| 亚洲精品99久久久久| 欧美黑人巨大xxx极品| 欧美一级片久久久久久久| 精品免费在线观看| 欧美理论片在线观看| 国产精品女主播| 欧美裸体视频网站| 欧美日韩在线影院| 精品视频在线播放色网色视频| 91亚洲精品久久久久久久久久久久| 亚洲午夜性刺激影院| 国产精品久久久久久av福利| 九九热最新视频//这里只有精品| 国产专区精品视频| 91亚洲精华国产精华| 国产精品免费看久久久香蕉| 欧美日韩国产限制| 国产国产精品人在线视| 中文字幕在线国产精品| 欧美在线视频一区| 4p变态网欧美系列| 国产高清在线不卡| 日韩中文字幕在线视频播放| 久久五月天综合| 日韩精品小视频| 日韩在线观看免费| 97人人模人人爽人人喊中文字| 成人黄色免费网站在线观看| 最近中文字幕日韩精品| 欧美大片免费看| 精品色蜜蜜精品视频在线观看| 亚洲精品电影久久久| 91日本在线观看| 久久久久久国产三级电影| 成人国内精品久久久久一区| 欧美大秀在线观看| 91精品国产自产在线观看永久| 欧美怡春院一区二区三区| 精品国产老师黑色丝袜高跟鞋| 色先锋久久影院av| 日本成人激情视频| 日韩中文在线中文网在线观看| 色婷婷久久一区二区| 51视频国产精品一区二区| 国产成人精彩在线视频九色| 国产精品日韩欧美综合| 中文字幕亚洲欧美一区二区三区| 亚洲色图av在线| 国产欧美日韩中文字幕| 91成人性视频| 日韩精品免费一线在线观看| 97视频在线观看网址| 国产精品久久久久99| 欧美国产视频一区二区| 九九精品视频在线| 日韩电影中文字幕在线观看| 久青草国产97香蕉在线视频| 97久久久免费福利网址| 久久精品99无色码中文字幕| 亚洲第一福利网站| 中文字幕亚洲综合久久| 日韩在线视频免费观看高清中文| 在线播放国产一区二区三区| xvideos国产精品| 亚洲国产欧美自拍| 欧美日韩在线视频一区二区| 欧美日本啪啪无遮挡网站| 国产成人综合久久| 国产日韩在线免费| 亚洲精品不卡在线| 国产成人一区二区三区小说| 欧美日韩中文字幕| 日韩精品久久久久久福利| 亚洲免费av片| 国产亚洲欧洲高清一区| 深夜成人在线观看| 91高清在线免费观看| 色综合天天狠天天透天天伊人| 欧美日韩免费在线观看| 高清一区二区三区日本久| 亚洲xxxxx| 国产精品中文字幕久久久| 欧美日韩亚洲系列| 2021久久精品国产99国产精品| 欧美性生交xxxxx久久久| 色综合伊人色综合网| 国产精品一区久久久| 国产精品免费福利| 亚洲精品一二区| 国产精品亚发布| 日韩电影大全免费观看2023年上| 最近日韩中文字幕中文| 欧美日韩在线视频观看| 久久99热精品这里久久精品| 欧美日韩免费网站| 亚洲综合中文字幕在线观看| xxx一区二区| 亚洲图片在线综合| 欧美精品久久久久a| 国产亚洲精品久久久久久牛牛| 正在播放欧美一区| 日本精品久久电影| 欧美电影在线观看| 社区色欧美激情 | 精品高清美女精品国产区| 亚洲欧洲免费视频| 国产精品嫩草视频| 精品高清美女精品国产区| 亚洲一区免费网站| 亚洲一区二区久久久久久久| 国产精品一区av| 成人h片在线播放免费网站| 国产精品白丝jk喷水视频一区| 97精品视频在线| 国产精品日韩一区| 91精品国产91久久久久久不卡| 久久久99免费视频| 成人国产精品av| 韩国v欧美v日本v亚洲| 91久久国产精品91久久性色| 亚洲精品午夜精品| 国产精品久久久久久久久| 国产成人精品免高潮在线观看| 91精品美女在线| 亚洲国产精品嫩草影院久久| 激情懂色av一区av二区av| 亚洲最大的网站| 欧美一区二区三区四区在线| 亚洲aⅴ男人的天堂在线观看| 欧美一级片久久久久久久| 国产精品午夜视频| 日韩在线观看电影| 日韩精品在线观看网站| 久久久久久久一区二区三区| 日韩精品视频观看| 亚洲一区二区三区视频播放| 久久国内精品一国内精品| 久久国产精品久久精品| 欧美成人精品一区二区三区| 欧美老妇交乱视频| 精品一区二区三区四区| 欧美日韩国产一区中文午夜| 亚洲自拍av在线| 亚洲成色777777女色窝| 成人高h视频在线| 日本高清久久天堂| 国产精选久久久久久| 国产一区二区三区18| 69精品小视频| 国内伊人久久久久久网站视频| 国产欧美日韩亚洲精品| 日韩福利伦理影院免费| 97成人在线视频| 久久亚洲影音av资源网| 国产精品视频免费观看www| 国产精品欧美日韩一区二区| 亚洲r级在线观看| 在线看福利67194| 色综合天天狠天天透天天伊人| 国产日韩av高清|