#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050
int n, m, q, k, v[N], ans;
// vector<int> grafo[N];
pii w[N];
string s;
bool check(int y){
set<int> caras, block;
for(int i = 1; i < k; i++) block.insert(v[i]);
int pos = y%n;
while(true){
if(caras.count(pos)) break;
caras.insert(pos);
if(block.count(pos)) return false;
pos += y;
pos %= n;
}
return true;
}
int32_t main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>k;
vector<int> primes;
for(int i = 1; i < k; i++){
cin>>v[i];
}
cin>>v[k];
if(k == 1){
cout<<n<<"\n";
return 0;
}
int x = __gcd(v[k], n), menorfat = (int)(2e18), can=0;
for(int j = 1; j*j <= x; j++){
int ok = 1;
if(x % j == 0){
int y = j;
int ok = 1;
int d = __gcd(y, n);
for(int p = 1; p < k; p++){
if(v[p] % y == 0) ok = 0;
}
if(ok) menorfat =min(menorfat, y), can=1;
ok = 1;
y = x/j;
d = __gcd(y, n);
for(int p = 1; p < k; p++){
if(v[p]%y == 0) ok = 0;
}
if(ok) menorfat =min(menorfat, y), can=1;
}
}
// assert(can);
cout<<n/menorfat<<"\n";
}
/*
CUIDADO COM MAXN, MOD, OVERFLOW
>Colocar (>DEFINE INT LONG LONG<) no inicio do template
>mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
>NAO ESQUECER DEFINE INT LONG LONG
> N = 1 ?
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}
Compilation message
sej.cpp: In function 'int32_t main()':
sej.cpp:67:8: warning: variable 'd' set but not used [-Wunused-but-set-variable]
67 | int d = __gcd(y, n);
| ^
sej.cpp:63:7: warning: unused variable 'ok' [-Wunused-variable]
63 | int ok = 1;
| ^~
sej.cpp:61:50: warning: variable 'can' set but not used [-Wunused-but-set-variable]
61 | int x = __gcd(v[k], n), menorfat = (int)(2e18), can=0;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
8 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
10 ms |
384 KB |
Output is correct |
4 |
Correct |
48 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
13 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
209 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
384 KB |
Output is correct |
2 |
Correct |
10 ms |
384 KB |
Output is correct |
3 |
Correct |
98 ms |
384 KB |
Output is correct |
4 |
Correct |
174 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
384 KB |
Output is correct |
2 |
Correct |
10 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
213 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
241 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
69 ms |
384 KB |
Output is correct |
4 |
Correct |
246 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
1152 KB |
Output is correct |
2 |
Correct |
533 ms |
2228 KB |
Output is correct |
3 |
Execution timed out |
1090 ms |
2176 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
1912 KB |
Output is correct |
2 |
Execution timed out |
1090 ms |
1912 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
2296 KB |
Output is correct |
2 |
Execution timed out |
1045 ms |
2296 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
2296 KB |
Output is correct |
2 |
Execution timed out |
1064 ms |
2304 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |