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

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

POJ - 2366 Sacrament of the sum 二分查找

2019-11-10 18:58:38
字體:
來源:轉載
供稿:網友

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
国产亚洲精品久久久久久牛牛| 亚洲高清av在线| 国产高清视频一区三区| 免费av在线一区| 久久成人国产精品| 国产日本欧美一区二区三区在线| 国产精品视频色| 亚洲精品午夜精品| 中文字幕一区二区三区电影| 亚洲理论片在线观看| 久久久精品视频在线观看| 国产精品露脸av在线| 麻豆乱码国产一区二区三区| 色婷婷久久av| 在线观看亚洲视频| 亚洲精品视频中文字幕| 欧美大胆在线视频| 91精品免费视频| 人人做人人澡人人爽欧美| 国产精品中文在线| 亚洲精品视频网上网址在线观看| 亚洲最大激情中文字幕| 国产精品尤物福利片在线观看| 91精品视频在线免费观看| 亚洲大胆人体在线| 国产精品美女免费看| 欧美精品中文字幕一区| 亚洲aa在线观看| 亚洲欧美另类自拍| 国产精品一区二区三区久久| 国产伊人精品在线| 97香蕉超级碰碰久久免费软件| 久久视频在线观看免费| 欧美性xxxx极品高清hd直播| 理论片在线不卡免费观看| 精品网站999www| 亚洲精品电影网在线观看| 青青青国产精品一区二区| 成人黄色大片在线免费观看| 日韩精品中文在线观看| 91精品中国老女人| 久久99精品久久久久久噜噜| 国产精品扒开腿做爽爽爽视频| 中文字幕一区二区三区电影| 俺去了亚洲欧美日韩| 日韩中文字幕免费视频| 2019av中文字幕| 亚洲免费精彩视频| 在线播放国产一区二区三区| 亚洲精品720p| 久久久中精品2020中文| 日韩av在线不卡| 亚洲欧美在线免费观看| 国产精品免费久久久久久| 亚洲视频精品在线| 69久久夜色精品国产69| 欧美国产日韩中文字幕在线| 在线国产精品播放| 精品久久久久久国产| 精品福利一区二区| 在线观看久久av| 色与欲影视天天看综合网| 92看片淫黄大片看国产片| 国产美女精品免费电影| 国产a级全部精品| 成人免费观看a| 中文字幕欧美精品日韩中文字幕| 日韩综合中文字幕| 九九热最新视频//这里只有精品| 亚洲最大福利网| 色综合久久精品亚洲国产| 亚洲欧美日韩精品久久亚洲区| 91在线免费视频| 日韩欧美在线视频免费观看| 国产精品扒开腿做爽爽爽的视频| 欧美日韩中文字幕在线视频| 亚洲午夜激情免费视频| 国产精品成久久久久三级| 亚洲大胆美女视频| 国产在线视频欧美| 亚洲国产欧美在线成人app| 国产精品久久久久久久美男| 亚洲美女av网站| 亚洲欧美一区二区三区情侣bbw| 日韩欧中文字幕| 欧美丰满老妇厨房牲生活| 亚洲国内高清视频| 宅男66日本亚洲欧美视频| 日韩av在线免费| 精品国产91久久久久久老师| 欧美激情一区二区三区在线视频观看| 国内自拍欧美激情| 日本午夜精品理论片a级appf发布| 亚洲黄色av女优在线观看| 国产精品91久久久久久| 久久99国产精品自在自在app| 欧美色道久久88综合亚洲精品| 国产精品久久久av| 国产精品视频一区二区三区四| 日韩在线观看av| 国产精品国产福利国产秒拍| 国产一区二区动漫| 欧洲成人午夜免费大片| 国产精品麻豆va在线播放| 成人欧美一区二区三区黑人孕妇| 日本精品久久久久久久| 精品久久久久久久久国产字幕| 欧美精品videosex性欧美| 国产精品男人的天堂| 亚洲高清不卡av| 欧美日韩成人黄色| 日韩专区在线播放| 美女av一区二区三区| 欧美日韩xxx| 国产69精品久久久久99| 美女啪啪无遮挡免费久久网站| 国产日产欧美精品| 久久久国产精品一区| 日韩精品一二三四区| 国产不卡av在线免费观看| 中国人与牲禽动交精品| 国产精品欧美激情| 97久久精品在线| 亚州成人av在线| 欧美贵妇videos办公室| 日本亚洲欧洲色α| 久久综合九色九九| 国产精品91久久久久久| 久久九九免费视频| 久久综合久久美利坚合众国| 亚洲第一精品电影| 欧美激情喷水视频| 日韩在线欧美在线国产在线| 亚洲四色影视在线观看| 2021久久精品国产99国产精品| 一区二区亚洲欧洲国产日韩| 中文字幕av一区二区三区谷原希美| 粉嫩老牛aⅴ一区二区三区| 丝袜美腿精品国产二区| 国产999精品久久久影片官网| 日本一区二区三区在线播放| 国产精品扒开腿爽爽爽视频| 日韩欧美主播在线| 成人www视频在线观看| 欧美日韩视频免费播放| 久久艹在线视频| 国产欧美一区二区三区视频| 中文字幕欧美视频在线| 精品国产31久久久久久| 欧美国产日韩免费| 国产视频亚洲精品| 国产日韩在线精品av| 久久国产精品影片| 亚洲欧美视频在线| 国内外成人免费激情在线视频| 亚洲电影成人av99爱色| 成人性生交大片免费观看嘿嘿视频| 美女999久久久精品视频| 国产一区二区色| 97国产精品久久| 色哟哟入口国产精品| 午夜精品国产精品大乳美女| 欧美日韩另类字幕中文| 国产精品久久77777|