【HDU5183】Negative and Positive (NP)
2015-03-08 19:16
260 查看
传送门: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; }
相关文章推荐
- Negative and Positive (NP) HDU5183 && Bestcoder#32
- HDU5183 Negative and Positive (NP) 散列表
- hdu5183---Negative and Positive (NP)(HASHMAP)
- hdu 5183 Negative and Positive (NP)
- Negative and Positive (NP) ( Hash 维护 )
- HDU 5183 Negative and Positive (NP)
- hdu 5183 Negative and Positive (NP)
- hdu5138 Negative and Positive (NP) 快速读入
- HDU 5183 Negative and Positive (NP) 前缀和+哈希
- hdu 5183 Negative and Positive (NP)【fast IO +哈希表】
- HDU 5183 Negative and Positive (NP) (set + 读入外挂 乱搞)
- Negative and Positive (NP) (hdu 5183 set+输入外挂)
- [HDOJ 5183] Negative and Positive (NP) 【Hash】
- 【Best Coder 】 32 B Negative and Positive (NP)
- hdu 5183 Negative and Positive (NP)
- hdu 5183 Negative and Positive (NP) (hash大法)
- HDU 5183 Negative and Positive (NP) (hashmap+YY)
- HDU 5183 Negative and Positive (NP) (hash)
- hdu 5183 Negative and Positive (NP)(STL-集合【HASH】)
- HDU 5183 - Negative and Positive (NP)(Hash)