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

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

POJ - 2366 Sacrament of the sum 二分查找

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

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
日韩精品丝袜在线| 欧美日韩亚洲一区二区| 热门国产精品亚洲第一区在线| 日韩欧美主播在线| 777国产偷窥盗摄精品视频| 久久激情五月丁香伊人| 欧美体内谢she精2性欧美| 日韩一区二区三区在线播放| 精品色蜜蜜精品视频在线观看| 国产精品久久久久久久久粉嫩av| 久久亚洲春色中文字幕| 国产欧美精品va在线观看| 欧美成人激情图片网| 久久婷婷国产麻豆91天堂| 亚洲久久久久久久久久| 亚洲精品福利视频| 91成人免费观看网站| 欧美激情欧美狂野欧美精品| 91成人在线播放| 亚洲美女中文字幕| 精品av在线播放| 国产一区二区日韩精品欧美精品| 日韩中文字幕国产| 韩国三级电影久久久久久| 欧美激情国产日韩精品一区18| 中文字幕av一区二区三区谷原希美| 欧美视频裸体精品| 成人做爰www免费看视频网站| 国产裸体写真av一区二区| 日韩有码在线电影| 久久精品国产一区二区三区| 日韩精品视频在线播放| 国产精品99蜜臀久久不卡二区| 亚洲肉体裸体xxxx137| 在线观看欧美www| 精品成人69xx.xyz| 久久久精品日本| 久久久免费av| 欧美日韩在线第一页| 亚洲午夜性刺激影院| 亚洲人成在线一二| 精品国产美女在线| 亚洲精品99久久久久中文字幕| 欧美日韩国产在线看| 亚洲午夜精品视频| 日韩av在线免费| 欧美中文字幕在线播放| 欧美一区二区视频97| 色综合色综合网色综合| 在线成人激情视频| 欧美日韩国产页| 国产精品视频色| 欧美性猛交xxxx免费看久久久| 最近2019中文字幕mv免费看| 国产午夜精品久久久| 国产91色在线播放| 亚洲一区二区自拍| 亚洲成人免费网站| 日本精品久久久久久久| 视频在线观看一区二区| 精品久久国产精品| 欧美性猛交xxxx免费看| 精品无人区太爽高潮在线播放| 欧美性感美女h网站在线观看免费| 欧美在线www| 91在线视频免费| 91免费在线视频| 国产精品视频在线播放| 91亚洲国产成人久久精品网站| 91免费综合在线| 97在线观看视频国产| 欧洲成人在线观看| 国产精品一二三在线| 亚洲高清色综合| 国产欧美日韩中文| 日韩精品中文在线观看| 久久五月天色综合| 欧美中在线观看| 欧美激情精品久久久久久变态| 亚洲三级av在线| 欧美日韩国产一区二区三区| 国产成人福利视频| 亚洲老司机av| 色综合伊人色综合网| 欧美电影免费观看高清| 日韩中文字在线| 91麻豆国产精品| 国产精品一区二区久久| 色偷偷亚洲男人天堂| 国产精品影院在线观看| 狠狠躁18三区二区一区| 日韩一级黄色av| 在线观看久久久久久| 日韩专区中文字幕| 国产成人小视频在线观看| 奇门遁甲1982国语版免费观看高清| 国产成人在线播放| 午夜免费在线观看精品视频| 日韩高清中文字幕| 精品国产31久久久久久| 亚洲人成免费电影| 国产精品777| 亚洲va电影大全| 久久综合88中文色鬼| 26uuu日韩精品一区二区| 日韩精品亚洲视频| 中文字幕成人在线| 亚洲欧美日韩网| 亚洲永久免费观看| 日韩精品视频免费在线观看| 久久国产精品免费视频| 97精品国产97久久久久久春色| 亚洲精品久久7777777| 国产精品一二三在线| 亚洲精品乱码久久久久久金桔影视| 午夜精品三级视频福利| 国产区精品在线观看| 中文字幕亚洲在线| 91久久国产综合久久91精品网站| 久久久亚洲成人| 91精品久久久久久久| 欧美在线视频观看免费网站| 亚洲男人天堂网| 国产亚洲欧洲在线| 午夜精品视频网站| 国产色综合天天综合网| 日韩欧美亚洲国产一区| 欧美一级淫片播放口| 精品综合久久久久久97| 日韩av影片在线观看| 国产深夜精品福利| 91美女片黄在线观| 欧美日韩国产色视频| 亚洲欧美日韩国产中文专区| 日本aⅴ大伊香蕉精品视频| 九九精品在线观看| 欧美激情亚洲另类| 国产精品夫妻激情| 国产精品免费网站| 日韩精品免费电影| 欧美在线视频免费观看| 91国产精品电影| 亚洲精品国产suv| 欧美日韩加勒比精品一区| 欧美理论在线观看| 一区二区日韩精品| 日本精品视频在线| 欧美丰满少妇xxxxx| 久热在线中文字幕色999舞| 欧美精品一本久久男人的天堂| 法国裸体一区二区| 国产精品久久久久久久久影视| 国产亚洲一级高清| 欧美极品美女视频网站在线观看免费| 久久久999精品视频| 日韩高清电影好看的电视剧电影| 国产精品视频午夜| 日韩中文字幕在线| 亚洲精品二三区| 国产精品6699| 日韩av毛片网| 亚洲第一区在线观看| 国产精品老女人视频| 色青青草原桃花久久综合|