标签:app scanf post art while ons ble lin queue
http://acm.hdu.edu.cn/showproblem.php?pid=4768
貌似非常多人是用的二分
可是更好的做法貌似还是异或
对于第k个人。假设他接到偶数个传单。那么异或的结果还是0
就是说op记录全部收到传单的人次的总的异或值。那么由于仅仅有一个是收到奇数次。所以异或值就是他的编号,至于收到几次,在O(n)能够计算
//#pragma comment(linker, "/STACK:102400000,102400000") #include <cstdio> #include <cstring> #include <algorithm> #include <string> #include <iostream> #include <iomanip> #include <cmath> #include <map> #include <set> #include <queue> using namespace std; #define ls(rt) rt*2 #define rs(rt) rt*2+1 #define ll long long #define ull unsigned long long #define rep(i,s,e) for(int i=s;i<e;i++) #define repe(i,s,e) for(int i=s;i<=e;i++) #define CL(a,b) memset(a,b,sizeof(a)) #define IN(s) freopen(s,"r",stdin) #define OUT(s) freopen(s,"w",stdout) const ll ll_INF = ((ull)(-1))>>1; const double EPS = 1e-8; const double pi = acos(-1.0); const int INF = 100000000; const int MAXN = 20010 +20; int a[MAXN],b[MAXN],c[MAXN],n; int main() { while(~scanf("%d",&n)){ int op=0,cnt=0; for(int i=0;i<n;i++) { scanf("%d%d%d",&a[i],&b[i],&c[i]); for(int j=a[i];j<=b[i];j+=c[i]) op^=j; } for(int i=0;i<n;i++){ if(op>=a[i] && op <=b[i] && (op-a[i])%c[i]==0)cnt++; } if(cnt%2==0)printf("DC Qiang is unhappy.\n"); else printf("%d %d\n",op,cnt); } return 0; }
标签:app scanf post art while ons ble lin queue
原文地址:http://www.cnblogs.com/blfbuaa/p/6884424.html