Sacrament of the sum

避坑指南:WSL2网络模式修改导致无法上网的解决方案(附备份还原技巧) 本文深入解析WSL2默认网络隔离机制,并提供三种安全的端口互通方案,重点推荐通过配置Windows防火墙规则实现稳定访问。同时,针对网络配置修改可能引发的无法上网问题,给出了从重置配置到系统级备份的完整恢复指南,确保开发环境安全可靠。 阅读详情
F - Sacrament of the sum

Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

— 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. 

这道题求两组数之和能否等于10000,是“Can you find it?”的简化版。

代码:

<div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">#include<cstdio></span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">using namespace std;</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">int L1,L2;</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">],b[50010];
int main()</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">int a[5001</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">0{</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">while(scanf("%d",&L1)!=EOF){</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">   scanf("%d",&a[i]);
    </span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">    for(int i=0;i<L1;i++){</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">    </span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;"> }</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">    scanf("%d",&L2);</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">    for(int i=0;i<L2;i++){</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">t i=0;i<L1;i++){
    int l</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">        scanf("%d",&b[i]);</span></div><span style="font-family:SimSun;font-size:14px;">    }
int mark=0;
</span><div style="text-align: left;"></div><span style="font-family:SimSun;font-size:14px;">for(
i
</span><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">n=0,r=L2-1,mid;</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">    while(l<=r){</span></div><span style="font-family:SimSun;font-size:14px;">    mid=(l+r)/2;
</span><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">]==10000)
</span></div><span style="font-family:SimSun;font-size:14px;">    if(a[i]+b[mi
d</span><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">id]>10000)
        l=mid</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">       {printf("YES\n");</span></div><span style="font-family:SimSun;font-size:14px;">        mark=1;
</span><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">    else if(a[i</span></div><span style="font-family:SimSun;font-size:14px;">        break;}
</span><div style="text-align: left;"></div><span style="font-family:SimSun;font-size:14px;">]+b
[
</span><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">m+1;</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">    else</span></div><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">        r=mid-1;</span></div><span style="font-family:SimSun;font-size:14px;">    }
</span><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">(mark!=0)
     </span></div><span style="font-family:SimSun;font-size:14px;">    i
f   break;
}
</span><div style="text-align: left;"><span style="font-family:SimSun;font-size:14px;">rintf("NO\n</span></div><span style="font-family:SimSun;font-size:14px;">if(mark==0)
p"</span><span style="font-family:SimSun;font-size:14px;">);
}
</span><div style="text-align: left;"></div><span style="font-family:SimSun;font-size:14px;">return 0;
</span><div style="text-align: left;"></div><span style="font-family:SimSun;font-size:14px;">}
</span>



ADS重新安装失败排查指南:从注册表清理到环境变量配置 本文详细解析了ADS重新安装失败的常见原因及解决方案,包括注册表残留清理、license路径锁定处理和环境变量配置。通过分步指南和实用技巧,帮助工程师高效解决安装问题,确保软件正常运行。 阅读详情

相关推荐

win x64下安装oracle 12c出现[INS-30131]报错的解决方案

问题:  win x64下安装oracle 12c出现[INS-30131]报错的解决方案 安装oracle11g碰到“无法访问临时位置”的问题,详细信息如下: INS-30131] 执行安装程序验证所需的初始设置失败。 原因 - 无法访问临时位置。   操作 - 请确保当前用户具有访问临时位置所需的权限。   附加信息:  - 所有节点上的框架设置检查都失败  

一条道走到黑的GISer 1326

POJ2366

Sacrament of the sum Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2270 Accepted: 1015 Description — The Brother of mine, the Head of Monastic Order want

algzjh的博客 1207

UG\NX二次开发 找不到指定的dlx文件(Specified Dlx file not found)

有群友问:用Ctrl+U运行的时候就报错,找不到指定的dlx文件Specified Dlx file not found。怎么处理。

王牌飞行员_里海的博客 1080

算法实验T5——POJ 2366 Sacrament of the sum

由有序联想到二分,遍历其中一个序列,对于遍历的每一个数 x,在另一个序列二分搜索(10000 - x),时间复杂度O(nlogn)。已知两个给定的序列,一个升序排列,一个降序排列,在这两个序列中各找一个数,它们加 起来恰好等于 10000。

qq_43010742的博客 481

POJ 2366 Sacrament of the sum(二分查找)

#include #include using namespace std; const int maxn=50005; int a[maxn],b[maxn]; int m,n; int main() {   bool bs(int [],int,int,int );   int i,j;   while(scanf("%d",&m)!=EOF)   {     for(

Hot_Summer_Days的专栏 1050

POJ 2366 Sacrament of the sum(哈希)

题目:2366 题意:从两个有序列表中寻找是否存在两个数加和等于10000 题解:哈希 AC代码: #include<iostream> using namespace std; #define MAX 80000 #define mid 40000 #define target 10000 int a[MAX] = {0}; int main() { int n1, ...

qq_36552817的博客 485

C - Sacrament of the sum

Description — 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 more

geekword的专栏 540

poj 2366 Sacrament of the sum

Sacrament of the sumTime Limit:1000MS    Memory Limit:65536KB    64bit IO Format:%lld & %llu SubmitStatusPracticePOJ 2366 Description — The Brother of mine, the Head of Monastic Order w

Tyshawn的博客 725

POJ 2366 Sacrament of the sum

Sacrament of the sum Description — 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 t

nudt_oys的博客 326

1021. Sacrament of the Sum

1021. Sacrament of the Sum Time Limit: 1.0 second Memory Limit: 16 MB Background — The Brother of mine, the Head of Monastic Order wants to know tomorrow about the results long-term rese

_qing的专栏 569

【Hash】Sacrament of Sum

时间限制:1s 内存限制:16mb 兄弟们达成共识后,便各自回到他们自己的密室,到第二天,他们每个人都准备了一些对于他们来说可以拯救他们之间感情的数字,这些数字可以拯救他们的感情吗?你的程序应该决定,是否有可能从两个整数列表选择这样两个数字,它们的和为10000. 输入: 每堆数(共2堆)的输入格式如下:N(1<=N<=50000),以下N行为每堆数中所包含的数(每个数的大小在PASCAL

LCWLH 530

【模拟】Sacrament of Sum

Sacrament of Sum (sacra.pas/cpp/in/out) 时间限制:1s 内存限制:16mb   兄弟们达成共识后,便各自回到他们自己的密室,到第二天,他们每个人都准备了一些对于他们来说可以拯救他们之间感情的数字,这些数字可以拯救他们的感情吗?你的程序应该决定,是否有可能从两个整数列表选择这样两个数字,它们的和为10000. 输入: 每堆数(共2堆)的输

wu_yihao的专栏 561

URAL 1021 Sacrament of the Sum

题好长,,,,题意就是能否在两块里各找一个数和为10000.。。。。。。。。。。。。先想到将两个数组排序,,,大加小。。。。。。。但是超时了。。。。。。。应该就想到动态规划或者二分,,,,,,,

生成猫 398

2016ACM暑假集训 - Sacrament of the sum

Description — 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 m

Leo Pan的博客 325

poj2366_Sacrament of the sum

Sacrament of the sum Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description — The Brother of mine, the Head of Monastic Order wants to

baidu_29998627的博客 339

POJ - 2366 Sacrament of the sum

Sacrament of the sum Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u [Submit]   [Go Back]   [Status]   Description — The Brother of mine,

acm_1361677193的专栏 395

【POJ 2366】Sacrament of the sum

POJ 2366

shimmer641的博客 347

3、基于Python的人脸识别系统设计与实现.docx

这是我自己设计的一个人脸识别系统的课题,基于Python语言研发了人脸识别管理系统,并在Pycharm平台完成主要功能模块的分析与设计,在摄像头采集到完整人脸信息的同时,对人员的身份进行认证和管理。本文所设计的人脸识别系统一方面可以实现人员的安全认证功能,还能够给重要场所的人员管理提供安全保障,测试结果表明:该系统能够准确识别人脸信息,并显示当前人员的录入时名字,而没有录入的人脸显示unknown,为有效解决人员管理问题提供了参考。使得人员安全管理系统具备了更高的实用价值,有着巨大市场潜力和应用前景。以下是重要内容阐述:1、人脸识别部分主要是依靠人脸特征提取来实现;2、摄像头捕获人脸后,会进行图像预处理,包括噪声处理、光照预处理和几何预处理;3、采用卷积神经网络为人脸识别算法;4、基于Python和Pycharm平台来实现系统设计;5、通过CNN训练发现,能够对人脸进行准确识别,识别率高达97%;

graphics32-master

graphics32-master

上一篇: Pie
下一篇: Calculates The Numbers
沈无迹
博客等级 码龄13年 2粉丝 8原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值