C. Koxia and Number Theory (线性同余)https://codeforces.com/contest/1770/problem/C
https://codeforces.com/contest/1770/attachments/download/18470/editorial.pdf
这个pdf都写得很明白了,这个c题终于懂了,麻了à
本来只需要枚举n/2之内的质数,但是因为n很小,所以直接枚举n/2也可以
- 对于给定的
,让我们记 。条件「 对于 恒成 立」等价于「每个质数 只能整除至多一个 」。那么,对于一个质数 ,我们能否判断 , 是否总是整除至少两个 (无论 的取值)
点通我的就是这句话
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #include<bits/stdc++.h> #define debug1(a) cout<<#a<<'='<< a << endl; #define debug2(a,b) cout<<#a<<" = "<<a<<" "<<#b<<" = "<<b<<endl; #define debug3(a,b,c) cout<<#a<<" = "<<a<<" "<<#b<<" = "<<b<<" "<<#c<<" = "<<c<<endl; #define debug4(a,b,c,d) cout<<#a<<" = "<<a<<" "<<#b<<" = "<<b<<" "<<#c<<" = "<<c<<" "<<#d<<" = "<<d<<endl; #define debug5(a,b,c,d,e) cout<<#a<<" = "<<a<<" "<<#b<<" = "<<b<<" "<<#c<<" = "<<c<<" "<<#d<<" = "<<d<<" "<<#e<<" = "<<e<<endl; #define debug0(x) cout << "debug0: " << x << endl #define fr(t, i, n)for (long long i = t; i < n; i++) #define YES cout<<"Yes"<<endl #define nO cout<<"no"<<endl #define fi first #define se second #define int long long using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair< int , int > PII; typedef pair<LL,LL> PLL; //#pragma GCC optimize(3,"Ofast","inline") //#pragma GCC optimize(2) const int N = 110; int a[N]; bool solve() { int n;cin >> n; for ( int i = 0;i < n;i ++)cin >> a[i]; sort(a,a+n); for ( int i = 1;i < n;i ++) if (a[i] == a[i-1]) { return 0; } bool acc = 1; for ( int i = 2;i <= n;i ++) { vector< int > num(i,0); for ( int j = 0;j < n;j ++)num[a[j] % i]++; if (*min_element(num.begin(),num.end()) >= 2)acc = 0; } return acc; } signed main() { /* ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); */ int T = 1;cin >> T; while (T--){ puts (solve()? "YES" : "NO" ); } return 0; } /* */ |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析