C. Koxia and Number Theory (线性同余)https://codeforces.com/contest/1770/problem/C

https://codeforces.com/contest/1770/attachments/download/18470/editorial.pdf

这个pdf都写得很明白了,这个c题终于懂了,麻了àaijbj

本来只需要枚举n/2之内的质数,但是因为n很小,所以直接枚举n/2也可以

  • 对于给定的 x,让我们记 bi=ai+x。条件「 gcd(bi,bj)=1对于 恒成 1i<jn立」等价于「每个质数 p 只能整除至多一个 bi」。那么,对于一个质数  p,我们能否判断 p, 是否总是整除至少两个 bi(无论x的取值)

点通我的就是这句话

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;
}
/*
 
*/

  

posted @   俄罗斯刺沙蓬  阅读(136)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
返回顶端
点击右上角即可分享
微信分享提示