【HDU5183】Negative and Positive (NP)
来源:互联网 发布:python 线程同步 编辑:程序博客网 时间:2024/05/18 01:18
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5183
#include <cstdio>#include <algorithm>#include <iostream>#include <cmath>#include <stdio.h>#include <set>using namespace std;typedef long long LL;set<LL>s;LL a[1000005];inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); } return x*f;}int main(){ int t; int flag; scanf("%d",&t); int cnt=1; while(t--) { int n; LL k; n=read(); k=read(); for(int i=1; i<=n; i++) { a[i]=read(); if(i%2==0) a[i]=-a[i]; } printf("Case #%d: ", cnt++); for(int i=1; i<=n; i++) { a[i]+=a[i-1]; } flag=1; s.clear(); for(int i=n; i>=0&&flag; i--) { if(i%2==0) { if(s.find(a[i]+k)!=s.end()) flag=0; } else { if(s.find(a[i]-k)!=s.end()) flag=0; } s.insert(a[i]); } if(flag==0) puts("Yes."); else puts("No."); } return 0;}
0 0
- 【HDU5183】Negative and Positive (NP)
- Negative and Positive (NP) HDU5183 && Bestcoder#32
- hdu5183---Negative and Positive (NP)(HASHMAP)
- hdu 5183 Negative and Positive (NP)
- HDU 5183 Negative and Positive (NP)
- hdu5138 Negative and Positive (NP) 快速读入
- HDU 5183 - Negative and Positive (NP)(Hash)
- hdu 5183 Negative and Positive (NP)
- HDU 5183 Negative and Positive (NP) (hash)
- hdu 5183-Negative and Positive (NP)
- Negative and Positive (NP) ( Hash 维护 )
- hdu 5183 Negative and Positive (NP)
- 【Best Coder 】 32 B Negative and Positive (NP)
- hdu 5183 Negative and Positive (NP) (hash大法)
- [HDU 5183][BestCoder #32]Negative and Positive (NP) (STL模板)
- BestCoder Round #32.Negative and Positive (NP)——哈希
- hdu 5183-Negative and Positive (NP) (hash+输入外挂)
- Negative and Positive (NP) (hdu 5183 set+输入外挂)
- 远程debug tomcat
- DXperience重编译汉化的方法
- Git 分支相关
- chrome 控制台使用详解
- URAL 1718 . Rejudge(数学啊 )
- 【HDU5183】Negative and Positive (NP)
- printf和fprintf的区别
- 如何引用一个已经定义过的全局变量 与 全局变量可不可以定义在可被多个.C文件包含的头文件中
- 2.6 顶点数组
- 圆并模板
- XHTML 2.0与HTML 5之争
- 1084. Broken Keyboard (20)建立查询表
- CocoaPods pod install/pod update更新慢的问题
- PHP程序优化