cf1487
edu真不是个东西
A:arena
可以逮着一个人薅到死,所以除了最小的那个都可以。
B:cat cycle
找规律,如果n是偶数不会相遇,就是k步。
如果是奇数,第一步不考虑,然后每隔(n-3)/2跳一次,相当于多走一步
1 2 3 4 5 6 7 8 9 10 11 12
| per(){ ll n,k; cin>>n>>k; if(n%2==0){ cout<<(k%n==0? n:k%n)<<endl; }else{ int d=(n-3)/2; ll tmp=(k-1)/(d+1); k+=tmp; cout<<(k%n==0? n:k%n)<<endl; } }
|
C: Minimum Ties
将所有球队排成一环,一圈可以直接连。
奇数的可以全连上,偶数的对角不连
在n*n的矩阵中,取不含主对角线的上三角,若奇数,上半-1下半1,偶数中间插个0.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| const int maxn=1e4+100; int ans[maxn]; int main() { std::ios::sync_with_stdio(false);std::cin.tie(0); per(){ int n;cin>>n; if(n==2){ cout<<0<<endl; }else if(n==3){ cout<<1<<' '<<-1<<' '<<1<<endl; }else if(n==4){ cout<<"1 0 -1 1 0 1"<<endl; }else{ int ed=n*(n-1)/2; if(n%2==1){ int tot=0; int tr=(n-1)/2; for(int i=1;i<=n;++i) for(int j=i+1;j<=n;++j){ if(j-i<=tr){ ans[++tot]=1; }else{ ans[++tot]=-1; } } }else{ int tot=0; int tr=n/2; for(int i=1;i<=n;++i) for(int j=i+1;j<=n;++j){ if(j-i<tr){ ans[++tot]=1; }else if(j-i==tr){ ans[++tot]=0; }else { ans[++tot]=-1; } } } for(int i=1;i<=ed;++i){ cout<<ans[i]<<' '; }cout<<endl; } } }
|
D:Minimum Ties
化出$c-b=1$,故三个数最大的是$c=b+1$,则$b+1<=n$进而化出$a^2<=2n-1$,则可以直接求出最大的a,而2~a中所有奇数都行,即$(a-1)/2$
1 2 3 4 5
| per(){ int n;cin>>n; int ed=(int)sqrt(2*n-1)-1; cout<<ed/2<<endl; }
|