제출 #67691

#제출 시각아이디문제언어결과실행 시간메모리
67691tatatanXOR Sum (info1cup17_xorsum)C++11
0 / 100
1683 ms8164 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<int,int> #define LL long long #define st first #define nd second #define endl '\n' using namespace std; const int MAXN=1000005; int n,a[MAXN],b[MAXN]; LL ans; int main() { scanf("%d",&n); for(int i=0;i<n;++i) scanf("%d",&a[i]); for(int i=0;i<30;++i) { int xo=(1<<(i+1))-1,t1,t2,t3; LL cnt=0; for(int j=0;j<n;++j) { b[j]=xo&a[j]; } sort(b,b+n); for(int j=0;j<n;++j) { t1=lower_bound(b,b+n,(1<<i)-b[j])-b; t1=n-t1; t2=lower_bound(b,b+n,(1<<(i+1))-b[j])-b; t2=n-t2; t3=lower_bound(b,b+n,(1<<(i+1))+(1<<i)-b[j])-b; t3=n-t3; cnt+=(t1-(t2-t3)); } for(int j=0;j<n;++j) if((b[j]*2)&(1<<i)) --cnt; cnt/=2; for(int j=0;j<n;++j) if((b[j]*2)&(1<<i)) ++cnt; if(cnt&1) ans+=(1<<i); } int ans2=0; for(int i=0;i<n;++i) for(int j=i;j<n;++j) ans2^=a[i]+a[j]; printf("%d/n",ans2); }

컴파일 시 표준 에러 (stderr) 메시지

xorsum.cpp: In function 'int main()':
xorsum.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...