标签:include define clu its main click closed 时间 直接
随便写点题,按时间倒序随便刷刷
A.
如果有两个相等可以列等式\(i+a_{i \bmod n}=j+a_{j \bmod n}\)
令\(i=k_1n+p,j=k_2n+q\),则有\(k_1n+p+a_p=k_2n+q+a_q\)
即存在\(p,q\),\(p+a_p=q+a_q\)在\(mod n\)意义下相等,这个直接判就行了
1 #include<bits/stdc++.h> 2 #define maxn 200005 3 using namespace std; 4 int T,n; 5 int a[maxn]; 6 int main() 7 { 8 scanf("%d",&T); 9 while(T--) 10 { 11 scanf("%d",&n); 12 for(int i=0;i<n;++i)scanf("%d",&a[i]); 13 for(int i=0;i<n;++i)a[i]=((a[i]+i)%n+n)%n; 14 sort(a,a+n); 15 bool fl=0; 16 for(int i=1;i<n;++i)if(a[i]==a[i-1])fl=1; 17 if(fl)puts("NO"); 18 else puts("YES"); 19 } 20 }
标签:include define clu its main click closed 时间 直接
原文地址:https://www.cnblogs.com/uuzlove/p/12863639.html