数据有点水

P1247 取火柴游戏

优秀
by lqhsr @ 2019-07-24 21:19:00


```cpp #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #define rep(i,a,b,k) for(register ll i=a;i<=b;i+=k) #define drep(i,a,b,k) for(register ll i=a;i>=b;i-=k) #define ll long long #define il inline #define mod 1000000007 using namespace std; il ll read() { char ch=getchar(); ll f=1,x=0; while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar(); return x*=f; } int n,a[500005],s; int main() { n=read(); rep(i,1,n,1) a[i]=read(),s^=a[i]; if(!s) puts("lose"),exit(0); rep(i,1,n,1) { s=0; rep(j,1,n,1) if(j!=i) s^=a[j]; if(s<a[i]) { printf("%d %d\n",a[i]-s,i); a[i]=s; rep(i,1,n,1) printf("%d ",a[i]); return 0; } } return 0; } ``` $ n^2 $
by 越学越掂 @ 2019-07-24 21:27:33


|