buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n; cin >> n; set<ll> st; for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { ll t = n; while (t % i == 0) t /= i; if (t / i % i == 1) st.insert(i); } } for (ll i = 1; i * i <= n - 1;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n; cin >> n; set<ll> st; for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { ll t = n; while (t % i == 0) t /= i; if (t % i == 1) st.insert(i); } } for (ll i = 1; i * i <= n - 1; i++...
[["-", 15, 339, 51, 16, 31, 16, 31, 16, 17, 85], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 12, 22]]
1
175
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define F0R(i, a) FOR(i, 0, a) #define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i) #define R0F(i, a) ROF(i, 0, a) using ll = long long; using ld = long double; ll INF = LLONG_MAX; using vi = vector<int>; using vll ...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define F0R(i, a) FOR(i, 0, a) #define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i) #define R0F(i, a) ROF(i, 0, a) using ll = long long; using ld = long double; ll INF = LLONG_MAX; using vi = vector<int>; using vll ...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25]]
1
706
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define repr(i, n) for (int i = (n - 1); i >= 0; --i) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a)...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define repr(i, n) for (int i = (n - 1); i >= 0; --i) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a)...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25]]
1
358
def gen_divs(n): divs = [] for i in range(2, int(n ** 0.5) + 1): if n % i == 0: divs.append(i) if i != n // i: divs.append(n // i) return divs def divthensub(v, div): while v % div == 0: v //= div if v % div == 1: return True else...
def gen_divs(n): divs = [] for i in range(2, int(n ** 0.5) + 1): if n % i == 0: divs.append(i) if i != n // i: divs.append(n // i) return divs def divthensub(v, div): while v % div == 0: v //= div if v % div == 1: return True else...
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
142
#pragma warning(disable : 6031) #include <algorithm> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <string> #include <vector> int minimum(int a, int b) { return a < b ? a : b; } int maximum(int a, int b) { return a > b ? a : b; } // const long long mod = 1000000007; const long long mod ...
#pragma warning(disable : 6031) #include <algorithm> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <string> #include <vector> int minimum(int a, int b) { return a < b ? a : b; } int maximum(int a, int b) { return a > b ? a : b; } // const long long mod = 1000000007; const long long mod ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
421
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using namespace std; int main() { ll N; cin >> N; int ans = 0; for (ll i = 2; i * i <= (N - 1); ++i) { if ((N - 1) % i != 0) continue; ++ans; if (i * i != (N -...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using namespace std; int main() { ll N; cin >> N; int ans = 0; for (ll i = 2; i * i <= (N - 1); ++i) { if ((N - 1) % i != 0) continue; ++ans; if (i * i != (N -...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25]]
1
166
#include <bits/stdc++.h> using namespace std; long long int num_yakusu(long long int N) { long long int num = 0; for (long long int i = 1; i * i <= N; i++) { if (i * i == N) num++; else if (N % i == 0) num += 2; } return num; } long long int num_yakusu_neo(long long int N) { long long in...
#include <bits/stdc++.h> using namespace std; long long int num_yakusu(long long int N) { long long int num = 0; for (long long int i = 1; i * i <= N; i++) { if (i * i == N) num++; else if (N % i == 0) num += 2; } return num; } long long int num_yakusu_neo(long long int N) { long long in...
[["-", 64, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["+", 64, 9, 0, 52, 15, 339, 51, 16, 17, 20]]
1
262
#include <bits/stdc++.h> #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i) #define pb push_back #define eb emplace_back #define all(x) x.b...
#include <bits/stdc++.h> #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i) #define pb push_back #define eb emplace_back #define all(x) x.b...
[["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 25], ["+", 64, 1, 0, 2, 3, 4, 0, 16, 17, 85]]
1
471
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define ll long long const int mod = 1000000007; // const int mod = 998244353; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mi...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define ll long long const int mod = 1000000007; // const int mod = 998244353; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mi...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
819
import numpy as np N = int(input()) def divisor(N): x = np.arange(1, int(N**(1/2)), dtype=np.int64) div = set(x[N % x == 0]) return div | set(N // x for x in div) cand = divisor(N) | divisor(N - 1) def test(N, K): if K == 1: return False while N % K == 0: N //= K re...
import numpy as np N = int(input()) def divisor(N): x = np.arange(1, int(N**(1/2))+1, dtype=np.int64) div = set(x[N % x == 0]) return div | set(N // x for x in div) cand = divisor(N) | divisor(N - 1) def test(N, K): if K == 1: return False while N % K == 0: N //= K ...
[["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612]]
5
132
// 解き直し. // https://img.atcoder.jp/abc161/editorial.pdf #include <bits/stdc++.h> using namespace std; using LL = long long; #define repex(i, a, b, c) for (int i = a; i < b; i += c) #define repx(i, a, b) repex(i, a, b, 1) #define rep(i, n) repx(i, 0, n) #define repr(i, a, b) for (int i = a; i >= b; i--) #define pb push_...
// 解き直し. // https://img.atcoder.jp/abc161/editorial.pdf #include <bits/stdc++.h> using namespace std; using LL = long long; #define repex(i, a, b, c) for (int i = a; i < b; i += c) #define repx(i, a, b) repex(i, a, b, 1) #define rep(i, n) repx(i, 0, n) #define repr(i, a, b) for (int i = a; i >= b; i--) #define pb push_...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25]]
1
263
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace __gnu_pbds; using namespace __gnu_cxx; using namespace std; using ll = long long; #define eb emplace_back #define pb push_back #define mp make_pair #define ff first #define ss s...
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace __gnu_pbds; using namespace __gnu_cxx; using namespace std; using ll = long long; #define eb emplace_back #define pb push_back #define mp make_pair #define ff first #define ss s...
[["+", 15, 339, 51, 2, 3, 4, 0, 16, 17, 72], ["+", 15, 339, 51, 2, 3, 4, 0, 16, 12, 13], ["+", 51, 16, 31, 2, 3, 4, 0, 16, 31, 22], ["+", 51, 16, 31, 2, 3, 4, 0, 16, 17, 85]]
1
639
import math N = int(input()) nn = int(math.sqrt(N)) # nn = int(N / 2) ans = 2 for x in range(2,nn+1): if N % x == 1: ans += 1 continue if N % x > 1: continue tmp = N while tmp > x: tmp = tmp / x if tmp % x == 1 : ans += 1 break ...
import math N = int(input()) nn = int(math.sqrt(N)) # nn = int(N / 2) ans = 1 for x in range(2,nn+1): if N % x == 1: ans += 1 continue if N % x > 1: continue tmp = N while tmp > x: tmp = tmp / x if tmp % x == 1 : ans += 1 break ...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
129
#include <bits/stdc++.h> const int INF = 1e9; const int MOD = 1e9 + 7; const long long LINF = 1e18; #define dump(x) cout << 'x' << ' = ' << (x) << ` `; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOREACH(x, ...
#include <bits/stdc++.h> const int INF = 1e9; const int MOD = 1e9 + 7; const long long LINF = 1e18; #define dump(x) cout << 'x' << ' = ' << (x) << ` `; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOREACH(x, ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 338, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 338, 8, 9, 0, 57, 64, 9, 0, 46]]
1
649
n = int(input()) def make_divisors(n): #約数を列挙する関数 divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() divisors.remove(1) return divisors ans = make_divisors(n-1) #n-...
n = int(input()) def make_divisors(n): #約数を列挙する関数 divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() divisors.remove(1) return divisors ans = make_divisors(n-1) #n-...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
151
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define rep(i, n) for (int i = 0; ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define rep(i, n) for (int i = 0; ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
648
from math import sqrt, ceil def factors_set(number): factors = set() for i in range(1, ceil(sqrt(number))): if number % i == 0: factors.add(i) factors.add(number // i) return factors N = int(input()) Ks = factors_set(N-1) | factors_set(N) Ks.remove(1) ans = 0 for K in Ks:...
from math import sqrt, ceil def factors_set(number): factors = set() for i in range(1, ceil(sqrt(number))+1): if number % i == 0: factors.add(i) factors.add(number // i) return factors N = int(input()) Ks = factors_set(N-1) | factors_set(N) Ks.remove(1) ans = 0 for K in K...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
118
#include <bits/stdc++.h> #define FAST_IO \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define SIZE(arr) ((int)arr.size()) ...
#include <bits/stdc++.h> #define FAST_IO \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define SIZE(arr) ((int)arr.size()) ...
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
221
#include <bits/stdc++.h> using namespace std; typedef long long LL; LL calc(LL k, LL n) { if (n < k) return k; else if (n % k == 0) return calc(k, n / k); else return n % k; } int main(void) { LL n; scanf("%lld", &n); LL x; x = n - 1; LL res = 0; for (LL i = 1; i * i <= x; i++) { if (x...
#include <bits/stdc++.h> using namespace std; typedef long long LL; LL calc(LL k, LL n) { if (n < k) return n; else if (n % k == 0) return calc(k, n / k); else return n % k; } int main(void) { LL n; scanf("%lld", &n); LL x; x = n - 1; LL res = 0; for (LL i = 1; i * i <= x; i++) { if (x...
[["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22], ["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22]]
1
204
import math N = int(input()) # 割れるだけ割る KMAX = math.floor(math.sqrt(N)) + 1 Kn = [N] # N の約数であるような K Kn1 = [N-1] # N - 1 の約数であるような K # N の約数であるような K (Kn)を求める for K in range(2,KMAX): if N % K == 0: Kn.append(K) tmp = N//K if tmp == K: continue Kn.append(N//K) ...
import math N = int(input()) # 割れるだけ割る KMAX = math.floor(math.sqrt(N)) + 1 Kn = [N] # N の約数であるような K Kn1 = [N-1] # N - 1 の約数であるような K # N の約数であるような K (Kn)を求める for K in range(2,KMAX): if N % K == 0: Kn.append(K) tmp = N//K if tmp == K: continue Kn.append(N//K) ...
[["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 267], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22]]
5
194
def calc_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() return divisors def div_or_sub(n, k): while k <= n: if n % k == 0: n //= ...
def calc_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() return divisors def div_or_sub(n, k): while k <= n: if n % k == 0: n //= ...
[["+", 36, 36, 0, 656, 0, 7, 12, 206, 0, 70], ["+", 0, 656, 0, 7, 12, 206, 206, 663, 0, 612], ["+", 0, 656, 0, 7, 12, 206, 206, 663, 0, 102], ["+", 36, 36, 0, 656, 0, 7, 12, 206, 0, 73]]
5
141
import math N = int(input()) ans = 0 for i in range(2, N + 1): if i * i > N: if N == 2: ans += 1 else: ans += 1 break if (N - 1) % i == 0: ans += 1 if (N - 1) // i != i: ans += 1 elif N % i == 0: cand = [i] if N /...
import math N = int(input()) ans = 0 for i in range(2, N + 1): if i * i > N: if N == 2: ans += 1 else: ans += 2 break if (N - 1) % i == 0: ans += 1 if (N - 1) // i != i: ans += 1 elif N % i == 0: cand = [i] if N /...
[["-", 75, 76, 8, 196, 0, 1, 0, 677, 12, 612], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 12, 612]]
5
134
import java.math.BigInteger; import java.util.*; public class Main { private static final int[] firstPrimes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}; private static ...
import java.math.BigInteger; import java.util.*; public class Main { private static final int[] firstPrimes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}; private static ...
[["-", 64, 196, 0, 1, 0, 492, 3, 4, 0, 499], ["+", 64, 196, 0, 1, 0, 492, 3, 4, 0, 499]]
3
938
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<ll> enumDivisor(ll n) { vector<ll> res; for (ll i = 1; i * i <= n; ++i) { if (n % i != 0) continue; res.emplace_back(i); if (i * i != n) res.emplace_back(n / i); } return res; } int main() { ll n; cin >> n; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<ll> enumDivisor(ll n) { vector<ll> res; for (ll i = 1; i * i <= n; ++i) { if (n % i != 0) continue; res.emplace_back(i); if (i * i != n) res.emplace_back(n / i); } return res; } int main() { ll n; cin >> n; ...
[["-", 0, 338, 8, 9, 0, 1, 0, 11, 17, 161], ["+", 0, 338, 8, 9, 0, 1, 0, 11, 17, 132]]
1
175
//“Make it work, make it right, make it fast.” – Kent Beck #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double dd; const int siz = 1e6 + 5; const int MOD = 1e9 + 7; #define endl '\n' #define deb(x) cout << #x << " = " << x << endl; ll fact1(ll n) { ll count = 0; for (ll i = 2; i * i ...
//“Make it work, make it right, make it fast.” – Kent Beck #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double dd; const int siz = 1e6 + 5; const int MOD = 1e9 + 7; #define endl '\n' #define deb(x) cout << #x << " = " << x << endl; ll fact1(ll n) { ll count = 0; for (ll i = 2; i * i ...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85]]
1
303
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author aajisaka */ #include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author aajisaka */ #include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...
[["+", 8, 9, 0, 7, 15, 16, 12, 23, 0, 24], ["+", 0, 7, 15, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 7, 15, 16, 12, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 23, 0, 25]]
1
392
def check(i): tot=k while(tot%i==0): tot//=i if(tot%i==1): setl.add(i) import math k=int(input()) if(k==2): print(2) exit() setl = set() setl.add(k); setl.add(k-1) for x in range(2,int(math.sqrt(k))+1): check(x) check(k//x) print(len(setl))
def check(i): tot=k while(tot%i==0): tot//=i if(tot%i==1): setl.add(i) import math k=int(input()) if(k==2): print(1) exit() setl = set() setl.add(k); setl.add(k-1) for x in range(2,int(math.sqrt(k))+1): check(x) check(k//x) print(len(setl))
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
117
n = int(input()) k = 2 count = set() while k * k <= n: if n % k == 1: count.add(k) count.add((n-1)//k) elif n % k == 0: n_copy = n while n_copy % k == 0: n_copy //= k if n_copy % k == 1: count.add(k) k += 1 count.add(n-1) count.add(n) print(len...
n = int(input()) k = 2 count = set() while k * k <= n: if n % k == 1: count.add(k) count.add((n-1)//k) elif n % k == 0: n_copy = n while n_copy % k == 0: n_copy //= k if n_copy % k == 1: count.add(k) k += 1 if n > 2: count.add(n-1) count.ad...
[["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102]]
5
105
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() const int mod = 1000000007, MAX = 400005, INF = 1 << 30; ll rui(ll a, ll b) { ll res = 1; for (int i = 0; i < b; i++) { if (log10(res) + log10(a) >= 13) return 1100000000000; res *= a; if (re...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() const int mod = 1000000007, MAX = 400005, INF = 1 << 30; ll rui(ll a, ll b) { ll res = 1; for (int i = 0; i < b; i++) { if (log10(res) + log10(a) >= 13) return 1100000000000; res *= a; if (re...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
378
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ul; typedef signed long long ll; mt19937 mt(time(nullptr)); // uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive bool solve(ul n, ul k) { if (k == 1) return false; while (n % k == 0) n /= k; return (n % k == ...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ul; typedef signed long long ll; mt19937 mt(time(nullptr)); // uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive bool solve(ul n, ul k) { if (k == 1) return false; while (n % k == 0) n /= k; return (n % k == ...
[["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 39, 78]]
1
286
#include <bits/stdc++.h> using namespace std; using llong = long long int; #define rep(i, n) for (int i = 0; i < n; ++i) #define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() const static int MOD = 1000000007; const static int...
#include <bits/stdc++.h> using namespace std; using llong = long long int; #define rep(i, n) for (int i = 0; i < n; ++i) #define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() const static int MOD = 1000000007; const static int...
[["-", 0, 9, 0, 52, 15, 339, 51, 16, 17, 47], ["+", 0, 9, 0, 52, 15, 339, 51, 16, 17, 20], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
1,153
import math INT_MAX=10**18+7 MOD=10**9+7 def INPUT():return list(int(i) for i in input().split()) def LIST_1D_ARRAY(n):return [0 for _ in range(n)] def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)] ################################################################################# n=int(input()) def ...
import math INT_MAX=10**18+7 MOD=10**9+7 def INPUT():return list(int(i) for i in input().split()) def LIST_1D_ARRAY(n):return [0 for _ in range(n)] def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)] ################################################################################# n=int(input()) def ...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
257
import java.io.*; import java.lang.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWri...
import java.io.*; import java.lang.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWri...
[["-", 0, 52, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 57, 64, 196, 0, 1, 0, 27, 0, 29], ["+", 0, 57, 64, 196, 0, 1, 0, 27, 0, 68]]
3
1,191
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const double eps = 1e-8; const int NINF = 0xc0c0c0c0; const int INF = 0x3f3f3f3f; const ll mod = 1e9 + 7; const ll maxn = 1e6 + 5; int main() { ll n; cin >> n; ll res = 0; for (ll i = 1; i * i <= n - 1; i++) { if ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const double eps = 1e-8; const int NINF = 0xc0c0c0c0; const int INF = 0x3f3f3f3f; const ll mod = 1e9 + 7; const ll maxn = 1e6 + 5; int main() { ll n; cin >> n; ll res = 0; for (ll i = 1; i * i <= n - 1; i++) { if ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
233
#include <bits/stdc++.h> #define int long long using namespace std; const int MOD = 1000000007; signed main() { int N; cin >> N; set<int> ans; ans.insert(N); ans.insert(N - 1); for (int i = 2; i <= sqrt(N); i++) { if (N % i == 0) { //もしNの約数だったら int A = N; while (A % i == 0) A /= i;...
#include <bits/stdc++.h> #define int long long using namespace std; const int MOD = 1000000007; signed main() { int N; cin >> N; set<int> ans; ans.insert(N); if (N > 2) ans.insert(N - 1); for (int i = 2; i <= sqrt(N); i++) { if (N % i == 0) { //もしNの約数だったら int A = N; while (A % i == 0) ...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25]]
1
223
import sys sys.setrecursionlimit(10**9) N = int(input()) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() return divisors ds = set(make_divi...
import sys sys.setrecursionlimit(10**9) N = int(input()) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() return divisors ds = set(make_divi...
[["-", 0, 37, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 37, 0, 652, 3, 4, 0, 657, 17, 109]]
5
169
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long a = n - 1; Set<Long> set = new HashSet<>(); set.add(n); for (int i = 2; i < Math.sqrt(n) + 1; i++) { if (n % i == 0) { long b = n /...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long a = n - 1; Set<Long> set = new HashSet<>(); set.add(n); for (int i = 2; i < Math.sqrt(n) + 1; i++) { if (n % i == 0) { long b = n /...
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
3
229
#include <bits/stdc++.h> using namespace std; #define pp pair<int, int> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define ll long long #define ld long double #define all(a) (a).begin(), (a).end() #define mk make_pair ll mod = 998244353; int inf = 1000001000; ll INF = 1e18 + 5; ll MOD = 1000000007; int main(...
#include <bits/stdc++.h> using namespace std; #define pp pair<int, int> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define ll long long #define ld long double #define all(a) (a).begin(), (a).end() #define mk make_pair ll mod = 998244353; int inf = 1000001000; ll INF = 1e18 + 5; ll MOD = 1000000007; int main(...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
221
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; int main() { ll n; cin >> n; ll div = 2; ll ret = 0; if (n == 2) { ret++; } while (div < sqrt(n) + 1) { ll temp = n; if (temp % div == 0) ...
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; int main() { ll n; cin >> n; ll div = 2; ll ret = 0; if (n == 2) { ret--; } while (div < sqrt(n) + 1) { ll temp = n; if (temp % div == 0) ...
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68]]
1
181
require 'set'; require 'prime' INF=Float::INFINITY; MOD=10**9+7 n_orig = gets.chomp.to_i if n_orig == 2 puts 1 exit elsif n_orig == 3 puts 2 exit elsif n_orig == 4 puts 3 exit elsif n_orig == 5 puts 3 exit end de = false root = Math.sqrt(n_orig).to_i p ['root', root] if de div = n_orig - 1 ans = 0 2...
require 'set'; require 'prime' INF=Float::INFINITY; MOD=10**9+7 n_orig = gets.chomp.to_i if n_orig == 2 puts 1 exit elsif n_orig == 3 puts 2 exit elsif n_orig == 4 puts 3 exit elsif n_orig == 5 puts 3 exit end de = false root = Math.sqrt(n_orig).to_i p ['root', root] if de div = n_orig - 1 ans = 0 2...
[["+", 0, 121, 64, 749, 0, 121, 15, 738, 17, 98], ["+", 0, 121, 15, 738, 12, 738, 31, 738, 31, 22], ["+", 0, 121, 15, 738, 12, 738, 31, 738, 17, 85], ["+", 0, 121, 15, 738, 12, 738, 31, 738, 12, 22], ["+", 64, 749, 0, 121, 15, 738, 12, 738, 17, 47], ["+", 64, 749, 0, 121, 15, 738, 12, 738, 12, 22]]
4
161
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; #define INF ((1 << 30) - 1) #define LINF (1LL << 60) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; #define INF ((1 << 30) - 1) #define LINF (1LL << 60) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
361
#!/usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, random, itertools, math sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF(): return...
#!/usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, random, itertools, math sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF(): return...
[["+", 0, 14, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612]]
5
483
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9 + 7; const ll INF = 1e18; #define rep(i, m, n) for (ll i = (m); i <= (n); i++) #define zep(i, m, n) for (ll i = (m); i < (n); i++) #define rrep(i, m, n) for (ll i = (m); i >= (n); i--) #define print(x) cout <<...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9 + 7; const ll INF = 1e18; #define rep(i, m, n) for (ll i = (m); i <= (n); i++) #define zep(i, m, n) for (ll i = (m); i < (n); i++) #define rrep(i, m, n) for (ll i = (m); i >= (n); i--) #define print(x) cout <<...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 109]]
1
319
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; const int MOD = 1000000007; int main() { ll N; cin >> N; vector<ll> d; if (N == 2) { cout << 0 << endl; return 0; } for (ll i = 1; i <= sqrt(N); i++) { if (N % i == 0) { d.push...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; const int MOD = 1000000007; int main() { ll N; cin >> N; vector<ll> d; if (N == 2) { cout << 1 << endl; return 0; } for (ll i = 1; i <= sqrt(N); i++) { if (N % i == 0) { d.push...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
257
#include <bits/stdc++.h> using namespace std; bool vis[2020202]; vector<long long> v; int main() { for (int i = 2; i <= 1e6 + 1e5; i++) { if (!vis[i]) { v.push_back(i); for (int j = i + i; j <= 1e6 + 1e5; j += i) { vis[j] = true; } } } long long n; cin >> n; if (n == 1) { ...
#include <bits/stdc++.h> using namespace std; bool vis[2020202]; vector<long long> v; int main() { for (int i = 2; i <= 1e6 + 1e5; i++) { if (!vis[i]) { v.push_back(i); for (int j = i + i; j <= 1e6 + 1e5; j += i) { vis[j] = true; } } } long long n; cin >> n; if (n == 1) { ...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
334
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; int main() { ll N, ans = 0; cin >> N; for (ll K = 2; K * K <= N - 1; K++) { ll n = N; while (n % K == 0) n /= K; if (n % K == 1) { ans++; // cout << " K=" << K; } ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; int main() { ll N, ans = 0; cin >> N; for (ll K = 2; K * K <= N; K++) { ll n = N; while (n % K == 0) n /= K; if (n % K == 1) { ans++; // cout << " K=" << K; } } ...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 48]]
1
155
#include <bits/stdc++.h> using namespace std; #define p_ary(ary, a, b) \ do { \ cout << "["; \ for (int count = (a); coun...
#include <bits/stdc++.h> using namespace std; #define p_ary(ary, a, b) \ do { \ cout << "["; \ for (int count = (a); coun...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
592
N = int(input()) #N = 6 def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) ...
N = int(input()) import itertools #N = 6 def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.appen...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
329
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define REP(i, n) for (int i = 1; i <= (n); ++i) #define pa(x, n) \ for (ll i = 0; i < n; i++) { \ cout << (x[i]) << " \n"[i == n -...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define REP(i, n) for (int i = 1; i <= (n); ++i) #define pa(x, n) \ for (ll i = 0; i < n; i++) { \ cout << (x[i]) << " \n"[i == n -...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 60]]
1
458
/* lib.cpp */ #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define overload4(_1, _2, _3, _4, name...
/* lib.cpp */ #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define overload4(_1, _2, _3, _4, name...
[["-", 0, 57, 64, 37, 0, 2, 3, 4, 0, 13], ["+", 0, 57, 64, 37, 0, 2, 3, 4, 0, 13]]
1
3,261
// author:luckYrat(twitter:@luckYrat_) //<ここに一言> //せんげん! #include <iostream> #include <algorithm> #include <cmath> #include <iomanip> #include <bitset> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <cctype> #include <climits> #include <utility> //なまえくー...
// author:luckYrat(twitter:@luckYrat_) //<ここに一言> //せんげん! #include <iostream> #include <algorithm> #include <cmath> #include <iomanip> #include <bitset> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <cctype> #include <climits> #include <utility> //なまえくー...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
504
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define srep(i, s, t) for (ll i = s; i < t; ++i) #define drep(i, n) for (ll i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair<int, int> P; #define yn ...
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define srep(i, s, t) for (ll i = s; i < t; ++i) #define drep(i, n) for (ll i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair<int, int> P; #define yn ...
[["-", 64, 9, 0, 52, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 52, 15, 339, 51, 16, 17, 20]]
1
291
a=int(input()) def div(n): div=set() for i in range(1, int(n**0.5)+1): if n % i == 0: div.add(i) div.add(n//i) if i != n // i: div.add(i) return div s=list((div(a)|div(a-1))|div(a+1)) def x(n,k): if k==1: return False else: while n>1 an...
a=int(input()) def div(n): div=set() for i in range(1, int(n**0.5)+1): if n % i == 0: div.add(i) div.add(n//i) if i != n // i: div.add(i) return div s=list((div(a)|div(a-1))|div(a+1)) def x(n,k): if k==1: return False else: while n>1 an...
[["+", 0, 52, 15, 679, 12, 666, 0, 657, 17, 33], ["+", 0, 52, 15, 679, 12, 666, 0, 657, 12, 612], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
179
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const ll MAX = 1e8; ll mod = 1e9 + 7; #define setbits(x) __builtin_popcount(x) #define setbitsll(x) __builtin_popcountll(x) //#define endl '\n' #define all(x) (x).begin(), (x).end() #define pb push_back #define se second...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const ll MAX = 1e8; ll mod = 1e9 + 7; #define setbits(x) __builtin_popcount(x) #define setbitsll(x) __builtin_popcountll(x) //#define endl '\n' #define all(x) (x).begin(), (x).end() #define pb push_back #define se second...
[["-", 0, 57, 64, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 57, 75, 76, 0, 1, 0, 27, 28, 22], ["-", 0, 57, 75, 76, 0, 1, 0, 27, 17, 29], ["-", 64, 9, 0, 57, 75, 76, 0, 1, 0, 35]]
1
465
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define int long long unordered_map<int, int> mp; bool check(int k, int n) { while (n % k == 0) { n /= k; } return n % k == 1; } void go(int divs, int n) { for (int i = 2; i * i <= divs; ++i) { if (divs % i == 0) { ...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define int long long unordered_map<int, int> mp; bool check(int k, int n) { while (n % k == 0) { n /= k; } return n % k == 1; } void go(int divs, int n) { for (int i = 2; i * i <= divs; ++i) { if (divs % i == 0) { ...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25]]
1
213
def divisor(x): div = [] for i in range(1,int(x**0.5)+1): if x%i == 0: div.append(i) if x != i*2: div.append(x//i) return div def calc(n,x): if x==1: return n while n>=x: if n%x == 0: n //= x else: n %= x return n n =...
def divisor(x): div = [] for i in range(1,int(x**0.5)+1): if x%i == 0: div.append(i) if x != i**2: div.append(x//i) return div def calc(n,x): if x==1: return n while n>=x: if n%x == 0: n //= x else: n %= x return n n ...
[["-", 64, 196, 0, 57, 15, 666, 0, 657, 17, 48], ["+", 64, 196, 0, 57, 15, 666, 0, 657, 17, 578]]
5
149
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <time.h> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define int long long #define ggr ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <time.h> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define int long long #define ggr ...
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 22]]
1
1,125
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; int ans = 0; for (ll i = 2; i * i <= n - 1; i++) { if ((n - 1) % i == 0) { ans++; if (i * i != n - 1) ans++; } } if (n >= 2) ans++; // n-1 for (ll i = 2; i * i <= n; i++) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; int ans = 0; for (ll i = 2; i * i <= n - 1; i++) { if ((n - 1) % i == 0) { ans++; if (i * i != n - 1) ans++; } } if (n > 2) ans++; // n-1 for (ll i = 2; i * i <= n; i++) { ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
217
#include <bits/stdc++.h> using namespace std; int main() { long long n, ans = 1, N, i; cin >> n; if (n == 2) { cout << 1 << endl; return 0; } for (N, i = 2; i * i <= n; i++) { for (N = n; N % i == 0; N /= i) ; ans += (N % i == 1) + (n % i == 1); } cout << ans - ((i - 1) * (i - 1) ==...
#include <bits/stdc++.h> using namespace std; int main() { long long n, ans = 2, N, i; cin >> n; if (n == 2) { cout << 1 << endl; return 0; } for (N, i = 2; i * i <= n; i++) { for (N = n; N % i == 0; N /= i) ; ans += (N % i == 1) + (n % i == 1); } cout << ans - ((i - 1) * (i - 1) ==...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
123
N = int(input()) def check(p): _N = N while _N%p == 0: _N //= p return (_N-1)%p == 0 n = int(N**0.5) + 1 P0 = set([N]) P1 = set([N-1]) for i in range(2, n+1): if (N-1)%i == 0: P1.add(i) P1.add((N-1)//i) if N%i == 0: P0.add(i) P0.add(N//i) P2.discard(1) P1.discard(1) ans = len(P1) for p ...
N = int(input()) def check(p): _N = N while _N%p == 0: _N //= p return (_N-1)%p == 0 n = int(N**0.5) + 1 P0 = set([N]) P1 = set([N-1]) for i in range(2, n+1): if (N-1)%i == 0: P1.add(i) P1.add((N-1)//i) if N%i == 0: P0.add(i) P0.add(N//i) P0.discard(1) P1.discard(1) ans = len(P1) for p ...
[["-", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22]]
5
160
#include <bits/stdc++.h> using namespace std; #define ll long long #define sint(a) scanf("%d", &a) #define sint2(a, b) scanf("%d %d", &a, &b) #define sll(a) scanf("%lld", &a) #define sll2(a, b) scanf("%lld %lld", &a, &b) #define mem(a, i) memset(a, i, sizeof(a)) #define pb push_back const double pi = acos(-1); const i...
#include <bits/stdc++.h> using namespace std; #define ll long long #define sint(a) scanf("%d", &a) #define sint2(a, b) scanf("%d %d", &a, &b) #define sll(a) scanf("%lld", &a) #define sll2(a, b) scanf("%lld %lld", &a, &b) #define mem(a, i) memset(a, i, sizeof(a)) #define pb push_back const double pi = acos(-1); const i...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85]]
1
275
#include <algorithm> #include <bitset> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> using namespace std; // #define for(i,a,b) for (int i=(a);i<(b);++i) typedef long long ll; typedef pair<ll, ll> P; #defin...
#include <algorithm> #include <bitset> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> using namespace std; // #define for(i,a,b) for (int i=(a);i<(b);++i) typedef long long ll; typedef pair<ll, ll> P; #defin...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
313
#pragma region template #include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9; long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, S, T, U, V, W, x, y, z; long long max_value = INF, max_index = -1...
#pragma region template #include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9; long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, S, T, U, V, W, x, y, z; long long max_value = INF, max_index = -1...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78]]
1
628
def divisors(n): ret=[] for i in range(2,int(n**0.5)+1): if n%i==0: ret.append(i) if n//i!=i: ret.append(n//i) return ret n=int(input()) divs1=divisors(n) divs2=divisors(n-1) cnt=len(divs2)-1 for val in divs1: if val==1: continue tmp=n while tmp%val==0: tmp=tmp//val if tmp...
def divisors(n): ret=[] for i in range(1,int(n**0.5)+1): if n%i==0: ret.append(i) if n//i!=i: ret.append(n//i) return ret n=int(input()) divs1=divisors(n) divs2=divisors(n-1) cnt=len(divs2)-1 for val in divs1: if val==1: continue tmp=n while tmp%val==0: tmp=tmp//val if tmp...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
127
n = int(input()) k = 2 count = 1 while k * k <= n: m = n while m % k == 0: m = m / k if m % k == 1: count += 1 k += 1 l = 1 while l * l < n: if (n - 1) % l == 0: count += 1 l += 1 if n == 2: print(1) else: print(count)
n = int(input()) k = 2 count = 1 while k * k <= n: m = n while m % k == 0: m = m / k if m % k == 1: count += 1 k += 1 l = 1 while l * l < n - 1: if (n - 1) % l == 0: count += 1 l += 1 if n == 2: print(1) else: print(count)
[["+", 0, 656, 0, 52, 15, 666, 0, 657, 17, 33], ["+", 0, 656, 0, 52, 15, 666, 0, 657, 12, 612]]
5
91
#!/usr/bin/env python3 import math n = int(input()) if n == 2: print(1) exit() # n-1の約数を全列挙か、n の約数を全部探索して、n//k*p = 1+k*qになるかを確かめる def divisor(n): res = [n] for i in range(2,1+math.ceil(math.sqrt(n))): if n % i == 0: res.append(i) if i != n//i: res.append(n...
#!/usr/bin/env python3 import math n = int(input()) if n == 2: print(1) exit() # n-1の約数を全列挙か、n の約数を全部探索して、n//k*p = 1+k*qになるかを確かめる def divisor(n): res = [n] for i in range(2,1+math.floor(math.sqrt(n))): if n % i == 0: res.append(i) if i != n//i: res.append(...
[["-", 3, 4, 0, 657, 12, 652, 63, 319, 319, 22], ["+", 3, 4, 0, 657, 12, 652, 63, 319, 319, 22]]
5
151
#include <bits/stdc++.h> using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(), A.end() #define RALL(A) A.rbegin(), A.rend() typedef long long LL; typedef pair<LL, LL> P; template <class T> inline bool chmax(T &a, T b) { if (...
#include <bits/stdc++.h> using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(), A.end() #define RALL(A) A.rbegin(), A.rend() typedef long long LL; typedef pair<LL, LL> P; template <class T> inline bool chmax(T &a, T b) { if (...
[["-", 51, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["-", 51, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 51, 16, 31, 16, 31, 16, 12, 2, 63, 22], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
1
466
#include <bits/stdc++.h> #define rep(a, b, c) for (int a = b; a <= c; a++) #define per(a, b, c) for (int a = b; a >= c; a--) #define pb push_back #define mk make_pair #define pii pair<int, int> #define fi first #define se second #define mem(a, b) memset(a, b, sizeof(a)) #define inf 0x3f3f3f3f #define ls(x) (x << 1) #de...
#include <bits/stdc++.h> #define rep(a, b, c) for (int a = b; a <= c; a++) #define per(a, b, c) for (int a = b; a >= c; a--) #define pb push_back #define mk make_pair #define pii pair<int, int> #define fi first #define se second #define mem(a, b) memset(a, b, sizeof(a)) #define inf 0x3f3f3f3f #define ls(x) (x << 1) #de...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
544
#include <bits/stdc++.h> #define REP(i, e) for (int(i) = 0; (i) < (e); ++(i)) #define FOR(i, b, e) for (int(i) = (b); (i) < (e); ++(i)) #define ALL(c) (c).begin(), (c).end() #define ACC(c) (accumulate(ALL(c), 0LL)) #define PRINT(x) cout << (x) << "\n" using namespace std; using ll = long long; using pint = pair<int, ...
#include <bits/stdc++.h> #define REP(i, e) for (int(i) = 0; (i) < (e); ++(i)) #define FOR(i, b, e) for (int(i) = (b); (i) < (e); ++(i)) #define ALL(c) (c).begin(), (c).end() #define ACC(c) (accumulate(ALL(c), 0LL)) #define PRINT(x) cout << (x) << "\n" using namespace std; using ll = long long; using pint = pair<int, ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
262
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
[["-", 0, 7, 8, 9, 0, 57, 64, 93, 0, 94], ["+", 0, 7, 8, 9, 0, 57, 64, 116, 0, 117], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
598
// by Top1 #include <bits/stdc++.h> #define f first #define s second #define int long long #define ld long double #define ull unsigned long long #define pii pair<int, int> #define pll pair<long, long> #define mp make_pair #define pb push_back #define pf push_front #define pp pop_back #define cerr cout #define rev reve...
// by Top1 #include <bits/stdc++.h> #define f first #define s second #define int long long #define ld long double #define ull unsigned long long #define pii pair<int, int> #define pll pair<long, long> #define mp make_pair #define pb push_back #define pf push_front #define pp pop_back #define cerr cout #define rev reve...
[["-", 8, 9, 0, 1, 0, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 1, 0, 16, 12, 16, 12, 13]]
1
287
import math N = int(input()) cnt = 0 if N == 2: print(2) exit() def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() return divisors res1 = ...
import math N = int(input()) cnt = 0 if N == 2: print(1) exit() def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() return divisors re...
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
172
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; #define rep(i, x) for (ll i = 0; i < (ll)(x); i++) #define rrep(i, x) for (ll i = (ll)(x)-1; 0 <= i; i--) #define reps(i, x) for (ll i = 1; i < (ll)(x) + 1; i++) #d...
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; #define rep(i, x) for (ll i = 0; i < (ll)(x); i++) #define rrep(i, x) for (ll i = (ll)(x)-1; 0 <= i; i--) #define reps(i, x) for (ll i = 1; i < (ll)(x) + 1; i++) #d...
[["-", 51, 218, 49, 185, 54, 55, 0, 56, 39, 40], ["+", 51, 218, 49, 185, 54, 55, 0, 56, 39, 78]]
1
535
n = gets.to_i def divisor(n) array = [] (1..Math.sqrt(n)).each do |i| if n % i == 0 array << i array << n / i unless i ** 2 == n end end array end ans = 1 ans += divisor(n-1).size divisor(n).each do |i| next if i == 1 temp = n while temp % i == 0 temp /= i end ans += 1 if (temp - 1) % i == 0 end ...
n = gets.to_i def divisor(n) array = [] (1..Math.sqrt(n)).each do |i| if n % i == 0 array << i array << n / i unless i ** 2 == n end end array end ans = 0 ans += divisor(n-1).size - 1 divisor(n).each do |i| next if i == 1 temp = n while temp % i == 0 temp /= i end ans += 1 if (temp - 1) % i == 0 ...
[["-", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612], ["+", 36, 36, 0, 493, 0, 755, 12, 738, 17, 33], ["+", 36, 36, 0, 493, 0, 755, 12, 738, 12, 612]]
4
111
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N; set<ll> s; cin >> N; for (ll i = 1; i * i <= N - 1; ++i) if ((N - 1) % i == 0) { s.insert(i); s.insert(N / i); } for (ll i = 1; i * i <= N; ++i) { if (N % i != 0) continue; ll t = N; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N; set<ll> s; cin >> N; for (ll i = 1; i * i <= N - 1; ++i) if ((N - 1) % i == 0) { s.insert(i); s.insert((N - 1) / i); } for (ll i = 1; i * i <= N; ++i) { if (N % i != 0) continue; ll t =...
[["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 25]]
1
203
#include <bits/stdc++.h> using namespace std; typedef long long ll; double getTime() { return clock() / (double)CLOCKS_PER_SEC; } void read(){}; template <typename T, typename... Args> void read(T &a, Args &...args) { cin >> a; read(args...); } void print(){}; template <typename T, typename... Args> void pri...
#include <bits/stdc++.h> using namespace std; typedef long long ll; double getTime() { return clock() / (double)CLOCKS_PER_SEC; } void read(){}; template <typename T, typename... Args> void read(T &a, Args &...args) { cin >> a; read(args...); } void print(){}; template <typename T, typename... Args> void pri...
[["+", 8, 9, 0, 37, 0, 16, 31, 16, 17, 109], ["+", 8, 9, 0, 37, 0, 16, 31, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 15, 339, 51, 16, 31, 23, 0, 25], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
318
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: map(int, stdin.readline().split()) nl = lambda: list(map(int, stdin.readline().split())) def divisor(n): ass = [] for i in range(1, int(n**0.5)+1): if n%i == 0: ass...
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: map(int, stdin.readline().split()) nl = lambda: list(map(int, stdin.readline().split())) def divisor(n): ass = [] for i in range(1, int(n**0.5)+1): if n%i == 0: ass...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 48], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
214
import java.util.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); HashSet<Long> l = new HashSet<>(); long j = s.nextLong(); long k = j - 1; for (long i = 2; i * i <= j; ++i) { if (j % i == 0) { f(i, j, l); f(j / i, j, l); ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); HashSet<Long> l = new HashSet<>(); long j = s.nextLong(); long k = j - 1; for (long i = 2; i * i <= j; ++i) { if (j % i == 0) { f(i, j, l); f(j / i, j, l); ...
[["-", 0, 492, 3, 4, 0, 510, 64, 16, 12, 499], ["+", 0, 492, 3, 4, 0, 510, 64, 16, 12, 499]]
3
213
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int using namespace __gnu_pbds; typedef tree<pair<ll, pair<ll, ll>>, null_type, less<pair<ll, pair<ll, ll>>>, rb_tree_tag, tree_order_statistics_node_update> ...
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int using namespace __gnu_pbds; typedef tree<pair<ll, pair<ll, ll>>, null_type, less<pair<ll, pair<ll, ll>>>, rb_tree_tag, tree_order_statistics_node_update> ...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85]]
1
408
#include <bits/stdc++.h> using namespace std; long long n; int main() { scanf("%lld", &n); if (n == 1) { printf("1\n"); return 0; } long long m; int cnt = 0; for (long long i = 2; i * i <= n; i++) { m = n; if (m % i) continue; while (m % i == 0) m = m / i; if (m % i == 1)...
#include <bits/stdc++.h> using namespace std; long long n; int main() { scanf("%lld", &n); if (n == 2) { printf("1\n"); return 0; } long long m; int cnt = 0; for (long long i = 2; i * i <= n; i++) { m = n; if (m % i) continue; while (m % i == 0) m = m / i; if (m % i == 1)...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
173
#include <bits/stdc++.h> using namespace std; using i64 = long long; #define endl "\n" int main() { i64 N; cin >> N; set<i64> ans; ans.insert(2); ans.insert(N); if (2 < N) ans.insert(N - 1); for (i64 i = 2; i * i < N; i++) { if ((N - 1) % i == 0) { ans.insert(i); ans.insert((N - 1) / ...
#include <bits/stdc++.h> using namespace std; using i64 = long long; #define endl "\n" int main() { i64 N; cin >> N; set<i64> ans; ans.insert(2); ans.insert(N); if (2 < N) ans.insert(N - 1); for (i64 i = 2; i * i <= N; i++) { if ((N - 1) % i == 0) { ans.insert(i); ans.insert((N - 1) /...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
169
#include <stdio.h> long long f(long long n, long long k) { return n % k ? n % k : n / k; } int main() { long long n, c = 0, i, j; scanf("%lld", &n); for (i = 1; i * i < n; i++) { if (n % i) continue; if (f(n, i) == 1) c++; if (f(n, n / i) == 1) c++; } if (i * i == n && f(n, i) ==...
#include <stdio.h> long long f(long long n, long long k) { return n % k ? n % k : f(n / k, k); } int main() { long long n, c = 0, i, j; scanf("%lld", &n); for (i = 2; i * i < n; i++) { if (n % i) continue; if (f(n, i) == 1) c++; if (f(n, n / i) == 1) c++; } if (i * i == n && f(n,...
[["+", 8, 9, 0, 37, 0, 41, 75, 2, 63, 22], ["+", 0, 37, 0, 41, 75, 2, 3, 4, 0, 24], ["+", 0, 37, 0, 41, 75, 2, 3, 4, 0, 21], ["+", 0, 37, 0, 41, 75, 2, 3, 4, 0, 22], ["+", 0, 37, 0, 41, 75, 2, 3, 4, 0, 25], ["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13]]
0
189
def divisors(n): x = [] m = 1 while m * m <= n: if n % m == 0: x.append(m) x.append(n // m) m += 1 return x n = int(input()) d = divisors(n) ans = 0 for k in d: if k == 1: continue nn = n while nn % k == 0: nn = nn // k ans += nn %...
def divisors(n): x = set() m = 1 while m * m <= n: if n % m == 0: x.add(m) x.add(n // m) m += 1 return x n = int(input()) d = divisors(n) ans = 0 for k in d: if k == 1: continue nn = n while nn % k == 0: nn = nn // k ans += nn % k ...
[["-", 8, 196, 0, 1, 0, 662, 12, 634, 0, 70], ["-", 8, 196, 0, 1, 0, 662, 12, 634, 0, 73], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22]]
5
116
N = int(input()) if N == 2: print(1) exit() if N == 3: print(2) exit() def yakusu(n): rn = int(n ** 0.5) ret = 2 for i in range(2, rn): if n % i == 0: ret += 2 if rn*rn == n: ret += 1 return ret #A = [True for i in range(10**6 + 1)] ans = 1 # K = N rn = int(N ** 0.5) for i in range(2, rn+1): if N % i...
N = int(input()) if N == 2: print(1) exit() if N == 3: print(2) exit() def yakusu(n): rn = int(n ** 0.5) ret = 2 for i in range(2, rn+1): if n % i == 0: ret += 2 if rn*rn == n: ret -= 1 return ret #A = [True for i in range(10**6 + 1)] ans = 1 # K = N rn = int(N ** 0.5) for i in range(2, rn+1): if N %...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 110]]
5
188
#include <bits/stdc++.h> using namespace std; #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() typedef pair<int, int> Pint; typedef pair<int64_t, int64_t> Pll; typedef int64_t ll; map<int64_t, int> prime_factor(int64_t n) { map<int64_t, int> ret; for (int64_t i = 2; i * i <= n; i++) {...
#include <bits/stdc++.h> using namespace std; #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() typedef pair<int, int> Pint; typedef pair<int64_t, int64_t> Pll; typedef int64_t ll; map<int64_t, int> prime_factor(int64_t n) { map<int64_t, int> ret; for (int64_t i = 2; i * i <= n; i++) {...
[["-", 8, 9, 0, 7, 8, 9, 0, 93, 0, 94], ["-", 8, 9, 0, 7, 8, 9, 0, 93, 0, 35], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
251
#define ll long long #define pub push_back #define pob pop_back #define puf push_front #define pof pop_front #define mp make_pair #define fo(i, n) for (ll i = 0; i < n; i++) //#include<bits/stdc++.h> #include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <...
#define ll long long #define pub push_back #define pob pop_back #define puf push_front #define pof pop_front #define mp make_pair #define fo(i, n) for (ll i = 0; i < n; i++) //#include<bits/stdc++.h> #include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 51, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 51, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["-", 15, 339, 51, 16, 12, 23, 0, 16, 17, 60], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 79], ["-", 64, 1, 0, 2, 3, 4, 0, 16, 31, 22]...
1
659
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; #define rep(i, a, b) for (int(i) = (a); (i) < (b); ++(i)) #define per(i, a, b) for (int(i) = (a); (i) >= (b); --(i)) #define pb push_back #define mp make_pair ...
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; #define rep(i, a, b) for (int(i) = (a); (i) < (b); ++(i)) #define per(i, a, b) for (int(i) = (a); (i) >= (b); --(i)) #define pb push_back #define mp make_pair ...
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]]
1
1,085
#!/usr/bin/python3 # -*- coding: utf-8 -*- def make_divisors(n): divisors = [] for i in range(2, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() return divisors n = int(input()) if n == 2: prin...
#!/usr/bin/python3 # -*- coding: utf-8 -*- def make_divisors(n): divisors = [] for i in range(2, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() return divisors n = int(input()) if n == 2: prin...
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
165
/// mAAria... #include <bits/stdc++.h> using namespace std; #define int long long #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); ...
/// mAAria... #include <bits/stdc++.h> using namespace std; #define int long long #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); ...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25]]
1
522
#include <algorithm> #include <bits/stdc++.h> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <iomanip> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #in...
#include <algorithm> #include <bits/stdc++.h> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <iomanip> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #in...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
454
#include <bits/stdc++.h> #include <stdio.h> #include <unistd.h> using namespace std; typedef long long lli; #define mod 1000000007 #define mod2 998244353 #define fori(n) for (int i = 0; i < n; i++) #define forj(n) for (int j = 0; j < n; j++) #define forr(c, n) for (int i = c; i < n; i++) #define forli(n) for (lli i = 0...
#include <bits/stdc++.h> #include <stdio.h> #include <unistd.h> using namespace std; typedef long long lli; #define mod 1000000007 #define mod2 998244353 #define fori(n) for (int i = 0; i < n; i++) #define forj(n) for (int j = 0; j < n; j++) #define forr(c, n) for (int i = c; i < n; i++) #define forli(n) for (lli i = 0...
[["-", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13]]
1
657
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define mp make_pair #define pp pair<ll, ll> #define vi vector<pair<pp, pp>> #define pq_min priority_queue<ll, vector<ll>, greater<ll>> #define pq_max priority_queue<ll> #define f(i, a, b) for (ll ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define mp make_pair #define pp pair<ll, ll> #define vi vector<pair<pp, pp>> #define pq_min priority_queue<ll, vector<ll>, greater<ll>> #define pq_max priority_queue<ll> #define f(i, a, b) for (ll ...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
414
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <limits.h> #include <map> #include <numeric> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() cons...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <limits.h> #include <map> #include <numeric> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() cons...
[["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 24], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 33], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 25]]
1
235
#include <bits/stdc++.h> #define ALL(a) (a).begin(), (a).end() #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<long long, long long> Pll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<long long> vll; typedef...
#include <bits/stdc++.h> #define ALL(a) (a).begin(), (a).end() #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<long long, long long> Pll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<long long> vll; typedef...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
462
#include <bits/stdc++.h> using namespace std; #define Fast \ ios_base::sync_with_stdio(false); \ cin.tie(nullptr); \ cout.tie(nullptr); #define f...
#include <bits/stdc++.h> using namespace std; #define Fast \ ios_base::sync_with_stdio(false); \ cin.tie(nullptr); \ cout.tie(nullptr); #define f...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
458
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define pb push_back #define lowbit(x) ((x) & (-x)) #define inf 0x3f3f3f3f #define endl "\n" #define MP(x, y) (make_pair(x, y)) #define pll pair<int, int> #define pi 3.1415926535 using namespace std; ll n; bool check(ll x) { ll p = n; whil...
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define pb push_back #define lowbit(x) ((x) & (-x)) #define inf 0x3f3f3f3f #define endl "\n" #define MP(x, y) (make_pair(x, y)) #define pll pair<int, int> #define pi 3.1415926535 using namespace std; ll n; bool check(ll x) { ll p = n; whil...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
295
n=int(input()) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() return divisors d=make_divisors(n)[1:] l=make_divisors(n-1)[1:] ans=0 for i in d...
n=int(input()) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() return divisors d=make_divisors(n)[1:] l=make_divisors(n-1)[1:] ans=0 for i in d...
[["+", 0, 7, 8, 196, 0, 52, 15, 666, 667, 60], ["+", 0, 7, 8, 196, 0, 52, 15, 666, 0, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
132
// Optional FAST //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native") // Required Libraries #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> ...
// Optional FAST //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native") // Required Libraries #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
668
#include <iostream> #define int long long using namespace std; int N; int tltle(int N) { int ans = 0; for (int k = 2; k <= N; k++) { int n = N; while (n >= k) { if (n % k == 0) n /= k; else n -= k; } if (n == 1) ans++; } return ans; } int tle(int N) { int a...
#include <iostream> #define int long long using namespace std; int N; int tltle(int N) { int ans = 0; for (int k = 2; k <= N; k++) { int n = N; while (n >= k) { if (n % k == 0) n /= k; else n -= k; } if (n == 1) ans++; } return ans; } int tle(int N) { int a...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
304
n = int(input()) lst = set() for i in range(2, int(n ** (1 / 2)) + 1): k = i while k <= n * i: k *= i if n % k == k // i: lst.add(i) break for i in range(2, int(n ** (1 / 2)) + 1): if n % i == 1: lst.add(i) lst.add((n - 1) // i) lst.add(n - 1) lst.add(n) print(len(lst))
n = int(input()) lst = set() for i in range(2, int(n ** (1 / 2)) + 1): k = i while k <= n * i: k *= i if n % k == k // i: lst.add(i) break for i in range(2, int(n ** (1 / 2)) + 1): if n % i == 1: lst.add(i) lst.add((n - 1) // i) if n > 2: lst.add(n - 1) lst.add(n) print(len(lst))
[["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102]]
5
130