problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using lint = long long; constexpr lint inf = 1LL << 60; constexpr lint mod = 1000000007; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int k; cin >> k; if (k % 2 == 0) { cout << -1 << "\n"; return 0; } lint res = 7 % k; lint ret = 1; while (res != 0) { res = (res * 10 + 7) % k; ret++; } cout << ret << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; using lint = long long; constexpr lint inf = 1LL << 60; constexpr lint mod = 1000000007; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int k; cin >> k; if (k % 2 == 0) { cout << -1 << "\n"; return 0; } lint res = 7 % k; lint ret = 1; while (res != 0) { res = (res * 10 + 7) % k; ret++; if (ret > k) { cout << -1 << "\n"; return 0; } } cout << ret << "\n"; return 0; }
insert
20
20
20
24
TLE
p02596
C++
Time Limit Exceeded
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (ll i = 0; i < ll(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < ll(b); i++) #define FORD(i, a, b) for (ll i = a; i > ll(b); i--) #define ALL(x) x.begin(), x.end() #define SIZE(x) ll(x.size()) #define INF 1000000000000 #define MOD 1000000007 #define MAXR 100000 #define PB push_back #define MP make_pair #define F first #define S second #define Umap unordered_map #define Uset unordered_set signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll K; cin >> K; ll ans = 0; if (K % 2 == 0 || K % 5 == 0) ans = -1; ll cnt = 1; ll warareru = 7; while (true) { ll amari = warareru % K; if (amari == 0) break; warareru = (amari * 10 + 7); cnt++; } cout << cnt << endl; return 0; }
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (ll i = 0; i < ll(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < ll(b); i++) #define FORD(i, a, b) for (ll i = a; i > ll(b); i--) #define ALL(x) x.begin(), x.end() #define SIZE(x) ll(x.size()) #define INF 1000000000000 #define MOD 1000000007 #define MAXR 100000 #define PB push_back #define MP make_pair #define F first #define S second #define Umap unordered_map #define Uset unordered_set signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll K; cin >> K; if (K % 2 == 0 || K % 5 == 0) { cout << -1 << endl; return 0; } ll cnt = 1; ll warareru = 7; while (true) { ll amari = warareru % K; if (amari == 0) break; warareru = (amari * 10 + 7); cnt++; } cout << cnt << endl; return 0; }
replace
29
32
29
33
TLE
p02596
Python
Time Limit Exceeded
K = int(input()) if K % 2 == 0: print(-1) else: r = 0 rem = 7 while True: r += 1 rem = rem % K if rem == 0: break rem = (rem * 10) + 7 print(r)
K = int(input()) if K % 2 == 0: print(-1) else: r = 0 rem = 7 while True: r += 1 rem = rem % K if rem == 0: break if r > K: r = -1 break rem = (rem * 10) + 7 print(r)
insert
11
11
11
14
TLE
p02596
Python
Time Limit Exceeded
K = int(input()) count = 1 check = 7 if K % 2 == 0 or K % 5 == 0: print(-1) else: while True: if check % K == 0: print(count) break else: count += 1 check = check * 10 + 7
K = int(input()) count = 1 check = 7 if K % 2 == 0 or K % 5 == 0: print(-1) else: while True: if check % K == 0: print(count) break else: count += 1 check = (check * 10 + 7) % K
replace
13
14
13
14
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long k; cin >> k; if (k % 2 == 0) { cout << -1 << endl; return 0; } int ans(7 % k); int cur(7 % k); int res(1); while (ans) { cur = cur * 10 % k; ans = (ans + cur) % k; res++; } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; return 0; } int ans(7 % k); int cur(7 % k); int res(1); while (ans) { cur = cur * 10 % k; ans = (ans + cur) % k; res++; } cout << res << endl; return 0; }
replace
6
7
6
7
TLE
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> //setprecision() #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using ll = long long; using namespace std; double Mcos(double k) { return cos(k * atan(1.0) * 4 / 180); } void monmo() {} int main() { int k; cin >> k; if (k % 2 == 0) { cout << "-1"; exit(0); } int s = 7; int hoji = 7; for (int i = 1;; i++) { if (s % k == 0) { cout << i; exit(0); } s %= k; hoji = (hoji * 10) % k; s += hoji; } }
#include <algorithm> #include <cmath> #include <iomanip> //setprecision() #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using ll = long long; using namespace std; double Mcos(double k) { return cos(k * atan(1.0) * 4 / 180); } void monmo() {} int main() { int k; cin >> k; if (k % 2 == 0) { cout << "-1"; exit(0); } int s = 7; int hoji = 7; for (int i = 1;; i++) { if (s % k == 0) { cout << i; exit(0); } s %= k; hoji = (hoji * 10) % k; s += hoji; if (i > 1000000) { cout << "-1"; exit(0); } } }
insert
33
33
33
38
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define arr(n) array<int, n> #define INF 1e9 typedef long long ll; typedef pair<int, int> pii; int main() { ll K; cin >> K; ll x = 0; rep(i, 300000000) { x = (x * 10 + 7) % K; if (x == 0) { cout << (i + 1) << endl; return 0; } } cout << -1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define arr(n) array<int, n> #define INF 1e9 typedef long long ll; typedef pair<int, int> pii; int main() { ll K; cin >> K; ll x = 0; rep(i, 30000000) { x = (x * 10 + 7) % K; if (x == 0) { cout << (i + 1) << endl; return 0; } } cout << -1 << endl; return 0; }
replace
12
13
12
13
TLE
p02596
Python
Time Limit Exceeded
# coding: utf-8 k = int(input()) kx = k if k % 2 == 1: while True: num = list(str(kx)) if all(kx == "7" for kx in num): print(len(str(kx))) break kx = kx + k else: print("-1")
# coding: utf-8 k = int(input()) ans = -1 x = 7 for i in range(k): if x % k == 0: ans = i + 1 break x = (10 * x + 7) % k print(ans)
replace
2
12
2
11
TLE
p02596
Python
Time Limit Exceeded
k = int(input()) if k % 2 == 0: print(-1) else: ans = 1 num = 7 % k temp = 7 % k while True: if num % k == 0: print(ans) break else: ans += 1 temp = temp * 10 % k num += temp % k num %= k
k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) else: ans = 1 num = 7 % k temp = 7 % k while True: if num % k == 0: print(ans) break else: ans += 1 temp = temp * 10 % k num += temp % k num %= k
replace
2
3
2
3
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long int using namespace std; int main() { int k; cin >> k; ll val = 7; int count = 0; bool temp = true; if (k % 2 == 0) { cout << -1 << endl; } else { while (true) { if (val % k == 0) { count++; break; } else if (count > k) { temp = false; } else { val = (val % k) * 10 + 7; count++; } } if (temp) { cout << count << endl; } else { cout << -1 << endl; } } }
#include <bits/stdc++.h> #define ll long long int using namespace std; int main() { int k; cin >> k; ll val = 7; int count = 0; bool temp = true; if (k % 2 == 0) { cout << -1 << endl; } else { while (true) { if (val % k == 0) { count++; break; } else if (count > k) { temp = false; break; } else { val = (val % k) * 10 + 7; count++; } } if (temp) { cout << count << endl; } else { cout << -1 << endl; } } }
insert
19
19
19
20
TLE
p02596
Python
Time Limit Exceeded
k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) else: ans = 1 num = 7 while True: if int(num) % k == 0: print(ans) break else: ans += 1 num += 7 * pow(10, ans - 1, k) num %= k
k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) else: ans = 1 num = 7 while True: if num % k == 0: print(ans) break else: ans += 1 num += 7 * pow(10, ans - 1, k) num %= k
replace
8
9
8
9
TLE
p02596
Python
Time Limit Exceeded
#!/usr/bin/env python3 def main(): K = int(input()) if K % 7 == 0: L = 9 * K / 7 else: L = 9 * K if L == 2 or L == 5: ans = -1 else: i = 1 tmp = 10 while True: tmp %= L if tmp == 1: ans = i break i += 1 tmp *= 10 print(ans) if __name__ == "__main__": main()
#!/usr/bin/env python3 def main(): K = int(input()) if K % 7 == 0: L = 9 * K / 7 else: L = 9 * K if L % 2 == 0 or L % 5 == 0: ans = -1 else: i = 1 tmp = 10 while True: tmp %= L if tmp == 1: ans = i break i += 1 tmp *= 10 print(ans) if __name__ == "__main__": main()
replace
9
10
9
10
TLE
p02596
Python
Time Limit Exceeded
K = int(input()) ans = 1 a = 7 i = K while K > 0: m = a % K if m == 0: print(ans) break else: ans += 1 a = m * 10 + 7 i -= 1 if m != 0: print(-1)
K = int(input()) ans = 1 a = 7 i = K while i > 0: m = a % K if m == 0: print(ans) break else: ans += 1 a = m * 10 + 7 i -= 1 if m != 0: print(-1)
replace
5
6
5
6
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; int remainder = 0; int digit = 0; while (true) { digit++; int i = (10 * remainder + 7) % K; if (i == remainder) break; remainder = i; if (remainder == 0) break; } if (remainder == 0) cout << digit << endl; else cout << -1 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; int remainder = 0; int digit = 0; while (digit < 1000000) { digit++; int i = (10 * remainder + 7) % K; if (i == remainder) break; remainder = i; if (remainder == 0) break; } if (remainder == 0) cout << digit << endl; else cout << -1 << endl; }
replace
8
9
8
9
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int n, sol, usu; int main() { ios::sync_with_stdio(false); cin >> n; if (n % 2 == 0) { cout << -1; return 0; } sol = 1; usu = 7; while (true) { if (usu % n == 0) { cout << sol; return 0; } usu = usu % n; usu = usu * 10 + 7; ++sol; } return 0; }
#include <bits/stdc++.h> using namespace std; int n, sol, usu; int main() { ios::sync_with_stdio(false); cin >> n; if (n % 2 == 0) { cout << -1; return 0; } sol = 1; usu = 7; while (true) { if (usu % n == 0) { cout << sol; return 0; } usu = usu % n; usu = usu * 10 + 7; ++sol; if (sol == 1000000) { cout << -1; return 0; } } return 0; }
insert
27
27
27
31
TLE
p02596
Python
Time Limit Exceeded
from sys import stdin input = stdin.buffer.readline k = int(input()) t, c = 7, 1 while t % k: t = t * 10 + 7 c += 1 print(c)
from sys import stdin input = stdin.buffer.readline k = int(input()) t = 7 for i in range(1, k + 1): if not t % k: print(i) exit() t = (t * 10 + 7) % k print(-1)
replace
4
9
4
11
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; const long long INF = 1LL << 60; int main() { int K, X = 7, count = 1; cin >> K; int N = X % K; if (K % 2 == 0) { cout << -1 << endl; return 0; } while (N != 0) { N = N * 10 + 7; N %= K; count++; } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; const long long INF = 1LL << 60; int main() { int K, X = 7, count = 1; cin >> K; int N = X % K; if (K % 2 == 0 || K % 5 == 0) { cout << -1 << endl; return 0; } while (N != 0) { N = N * 10 + 7; N %= K; count++; } cout << count << endl; }
replace
9
10
9
10
TLE
p02596
C++
Time Limit Exceeded
#pragma region #define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <cmath> #include <cstdint> #include <cstdlib> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; // #define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i)) #define rep(i, e) for (int(i) = 0; (i) < (e); ++(i)) #define rrep(i, s) for (int(i) = (s)-1; (i) >= 0; --(i)) #define all(x) x.begin(), x.end() #pragma region UnionFind struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) {} void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; #pragma endregion #pragma region GCD ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } #pragma endregion #pragma region LCM ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } #pragma endregion #pragma region chmin template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } #pragma endregion #pragma region chmax template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } #pragma endregion #pragma endregion int main() { int k; cin >> k; if (k == 7 || k == 1) { cout << 1 << endl; return 0; } int d = 7; int r = 0; int res = 0; do { if (d == 0) { cout << -1 << endl; return 0; } r += d % k; ++res; r %= k; d *= 10; d %= k; } while (r != 0); cout << res << endl; }
#pragma region #define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <cmath> #include <cstdint> #include <cstdlib> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; // #define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i)) #define rep(i, e) for (int(i) = 0; (i) < (e); ++(i)) #define rrep(i, s) for (int(i) = (s)-1; (i) >= 0; --(i)) #define all(x) x.begin(), x.end() #pragma region UnionFind struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) {} void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; #pragma endregion #pragma region GCD ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } #pragma endregion #pragma region LCM ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } #pragma endregion #pragma region chmin template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } #pragma endregion #pragma region chmax template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } #pragma endregion #pragma endregion int main() { int k; cin >> k; if (k == 7 || k == 1) { cout << 1 << endl; return 0; } int d = 7; int r = 0; int res = 0; do { if (d == 0 || res > 1e8) { cout << -1 << endl; return 0; } r += d % k; ++res; r %= k; d *= 10; d %= k; } while (r != 0); cout << res << endl; }
replace
96
97
96
97
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll k; cin >> k; ll a = 7; ll ans = 1; if (k % 2 == 0) { cout << -1 << endl; return 0; } while (1) { if (a % k == 0) { cout << ans << endl; return 0; } a = (a * 10 + 7) % k; ans++; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll k; cin >> k; ll a = 7; ll ans = 1; if (k % 2 == 0) { cout << -1 << endl; return 0; } while (1) { if (a % k == 0) { cout << ans << endl; return 0; } if (ans > k) { cout << -1 << endl; return 0; } a = (a * 10 + 7) % k; ans++; } }
insert
18
18
18
22
TLE
p02596
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #include <iomanip> #include <math.h> template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const int mod = 1000000007; const int INF = 1001001001; int main() { int K; cin >> K; int t = 7; vector<bool> use(K - 1, false); for (int i = 0; i < K; i++) { if (use[t % K]) { cout << -1 << endl; return 0; } if (t % K == 0) { cout << i + 1 << endl; return 0; } use[t % K] = true; t %= K; t *= 10; t += 7; } return 0; }
#include <bits/stdc++.h> using namespace std; #include <iomanip> #include <math.h> template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const int mod = 1000000007; const int INF = 1001001001; int main() { int K; cin >> K; int t = 7; vector<bool> use(K, false); for (int i = 0; i < K; i++) { if (use[t % K]) { cout << -1 << endl; return 0; } if (t % K == 0) { cout << i + 1 << endl; return 0; } use[t % K] = true; t %= K; t *= 10; t += 7; } return 0; }
replace
25
26
25
26
0
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using lint = long long; using P = pair<int, int>; using vec = vector<int>; using mat = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define endl "\n" constexpr int MOD = 1000000007; const int INF = 1 << 30; int main() { lint k; cin >> k; if (k == 2 || k == 5) { cout << "-1" << endl; exit(0); } lint cur = 7 % k; lint mul = 70; int res = 1; while (cur != 0) { cur += mul; cur %= k; mul *= 10; mul %= k; res++; } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using lint = long long; using P = pair<int, int>; using vec = vector<int>; using mat = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define endl "\n" constexpr int MOD = 1000000007; const int INF = 1 << 30; int main() { lint k; cin >> k; if (k == 2 || k == 5) { cout << "-1" << endl; exit(0); } lint cur = 7 % k; lint mul = 70; int res = 1; while (cur != 0) { cur += mul; cur %= k; mul *= 10; mul %= k; res++; if (res >= k + 2) { cout << "-1" << endl; exit(0); } } cout << res << endl; return 0; }
insert
32
32
32
36
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define pob pop_back #define ff first #define ss second #define endl "\n" #define all(a) a.begin(), a.end() #define debug(x) cout << x << endl; #define int long long #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ tree_order_statistics_node_update> /* 1) order_of_key (k) : Number of items strictly smaller than k . 2) find_by_order(k) : K-th element in a set (counting from zero). */ using namespace __gnu_pbds; using namespace std; using LD = long double; const int N = 1e6 + 1; const int mod = 1e9 + 7; const int INF = 1e18; int row[8] = {1, 1, 0, -1, -1, -1, 0, 1}; int col[8] = {0, -1, -1, -1, 0, 1, 1, 1}; void solve() { int k; cin >> k; int num = 7, cnt = 0; bool flg = true; while (num < N) { cnt++; if (num % k == 0) { flg = false; break; } num = num * 10 + 7; num %= k; } if (flg) cout << "-1"; else cout << cnt << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t = 1, i = 1; // cin >> t; while (t--) { // cout << "Case #" << i << ": "; solve(); // i++; } return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define pob pop_back #define ff first #define ss second #define endl "\n" #define all(a) a.begin(), a.end() #define debug(x) cout << x << endl; #define int long long #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ tree_order_statistics_node_update> /* 1) order_of_key (k) : Number of items strictly smaller than k . 2) find_by_order(k) : K-th element in a set (counting from zero). */ using namespace __gnu_pbds; using namespace std; using LD = long double; const int N = 1e6 + 1; const int mod = 1e9 + 7; const int INF = 1e18; int row[8] = {1, 1, 0, -1, -1, -1, 0, 1}; int col[8] = {0, -1, -1, -1, 0, 1, 1, 1}; void solve() { int k; cin >> k; int num = 7, cnt = 0; bool flg = true; while (cnt < N) { cnt++; if (num % k == 0) { flg = false; break; } num = num * 10 + 7; num %= k; } if (flg) cout << "-1"; else cout << cnt << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t = 1, i = 1; // cin >> t; while (t--) { // cout << "Case #" << i << ": "; solve(); // i++; } return 0; }
replace
32
33
32
33
TLE
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; int main() { ll n; cin >> n; if (n % 2 == 0) { cout << -1 << endl; } else { ll m = 7 % n; ll ten = 10; ll cnt = 1; while (m != 0) { cnt++; m += ten * 7 % n; m %= n; ten *= 10; ten %= n; } cout << cnt << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; int main() { ll n; cin >> n; if (n % 2 == 0 || n % 5 == 0) { cout << -1 << endl; } else { ll m = 7 % n; ll ten = 10; ll cnt = 1; while (m != 0) { cnt++; m += ten * 7 % n; m %= n; ten *= 10; ten %= n; } cout << cnt << endl; } return 0; }
replace
17
18
17
18
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; typedef vector<ll> vll; typedef vector<ld> vld; typedef vector<pll> vpl; typedef vector<vll> vvll; #define ALL(a) a.begin(), a.end() #define SZ(a) ((int)a.size()) #define FI first #define SE second #define REP(i, n) for (int i = 0; i < ((int)n); i++) #define REP1(i, n) for (int i = 1; i < ((int)n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define PB push_back #define EB emplace_back #define MP(a, b) make_pair(a, b) #define SORT_UNIQUE(c) \ (sort(c.begin(), c.end()), \ c.resize(distance(c.begin(), unique(c.begin(), c.end())))) #define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin()) #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define Decimal fixed << setprecision(20) #define INF 1000000000 #define LLINF 1000000000000000000LL const int inf = 1e9; const ll linf = 1LL << 50; const double eps = 1e-10; const int MOD = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll k; cin >> k; ll cnt = 0; ll rem = 0; ll power = 7; while (true) { cnt++; rem = (rem + power) % k; if (rem == 0) break; power = power * 10 % k; if (power == 0) { cnt = -1; break; } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; typedef vector<ll> vll; typedef vector<ld> vld; typedef vector<pll> vpl; typedef vector<vll> vvll; #define ALL(a) a.begin(), a.end() #define SZ(a) ((int)a.size()) #define FI first #define SE second #define REP(i, n) for (int i = 0; i < ((int)n); i++) #define REP1(i, n) for (int i = 1; i < ((int)n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define PB push_back #define EB emplace_back #define MP(a, b) make_pair(a, b) #define SORT_UNIQUE(c) \ (sort(c.begin(), c.end()), \ c.resize(distance(c.begin(), unique(c.begin(), c.end())))) #define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin()) #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define Decimal fixed << setprecision(20) #define INF 1000000000 #define LLINF 1000000000000000000LL const int inf = 1e9; const ll linf = 1LL << 50; const double eps = 1e-10; const int MOD = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll k; cin >> k; ll cnt = 0; ll rem = 0; ll power = 7; while (true) { cnt++; rem = (rem + power) % k; if (rem == 0) break; power = power * 10 % k; if (power == 0 || cnt >= 1e6 + 1) { cnt = -1; break; } } cout << cnt << endl; }
replace
59
60
59
60
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second using namespace std; long long power(long long x, unsigned long long y, long long p) { long long res = 1; x = x % p; // Update x if it is more than or // equal to p if (x == 0) return 0; // In case x is divisible by p; while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res * x) % p; // y must be even now y = y >> 1; // y = y/2 x = (x * x) % p; } return res; } int main() { int k; cin >> k; long long remain = 7 % k; long long counter = 1; while (remain) { remain = remain + 7 * power(10, counter, k); remain = remain % k; counter++; if (counter > 10000000) { cout << -1 << endl; return 0; } } cout << counter << endl; return 0; }
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second using namespace std; long long power(long long x, unsigned long long y, long long p) { long long res = 1; x = x % p; // Update x if it is more than or // equal to p if (x == 0) return 0; // In case x is divisible by p; while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res * x) % p; // y must be even now y = y >> 1; // y = y/2 x = (x * x) % p; } return res; } int main() { int k; cin >> k; long long remain = 7 % k; long long counter = 1; while (remain) { remain = remain + 7 * power(10, counter, k); remain = remain % k; counter++; if (counter > 1000000) { cout << -1 << endl; return 0; } } cout << counter << endl; return 0; }
replace
42
43
42
43
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll k; cin >> k; if (k % 2 == 0) { cout << -1 << endl; return 0; } ll ans = 0; ll now = 7; while (now % k != 0) { now *= 10; now += 7; now %= k; ans++; } cout << ans + 1 << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; return 0; } ll ans = 0; ll now = 7; while (now % k != 0) { now *= 10; now += 7; now %= k; ans++; } cout << ans + 1 << endl; }
replace
7
8
7
8
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; #define all(x) x.begin(), x.end() #define rep(i, j, n) for (long long i = j; i < (long long)(n); i++) #define _GLIBCXX_DEBUG #define MOD 1000000007 template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } //(a+b-1)/b ll k; ll f(ll a, ll b) { if (b == 0) return 1; if (b % 2 == 0) { ll t = f(a, b / 2); return t * t % k; } return a * f(a, b - 1) % k; } signed main() { cin >> k; if (k % 2 == 0) { cout << -1 << endl; return 0; } if (k % 7 == 0) k /= 7; ll j = 0; ll cnt = 0; ll ans = -1; rep(i, 0, 10000000) { j += f(10, cnt); if (j == k) { ans = cnt; break; } cnt++; j %= k; // cout<<j<<endl; } // if(k==ans)ans--; cout << ++ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; #define all(x) x.begin(), x.end() #define rep(i, j, n) for (long long i = j; i < (long long)(n); i++) #define _GLIBCXX_DEBUG #define MOD 1000000007 template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } //(a+b-1)/b ll k; ll f(ll a, ll b) { if (b == 0) return 1; if (b % 2 == 0) { ll t = f(a, b / 2); return t * t % k; } return a * f(a, b - 1) % k; } signed main() { cin >> k; if (k % 2 == 0) { cout << -1 << endl; return 0; } if (k % 7 == 0) k /= 7; ll j = 0; ll cnt = 0; ll ans = -2; rep(i, 0, 1000000) { j += f(10, cnt); if (j == k) { ans = cnt; break; } cnt++; j %= k; // cout<<j<<endl; } // if(k==ans)ans--; cout << ++ans << endl; return 0; }
replace
47
49
47
49
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll inf = 1000000000000000000, mod = 1000000007, BS, k; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ll n; cin >> n; if (n % 2 == 0) { cout << "-1"; } else { ll sum = 0, curr = 7; while (1) { if (curr % n == 0) { break; } curr = (curr * 10) % n; curr = (curr + 7) % n; sum++; } std::cout << sum + 1 << "\n"; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll inf = 1000000000000000000, mod = 1000000007, BS, k; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ll n; cin >> n; if (n % 5 == 0) { cout << "-1"; return 0; } if (n % 2 == 0) { cout << "-1"; } else { ll sum = 0, curr = 7; while (1) { if (curr % n == 0) { break; } curr = (curr * 10) % n; curr = (curr + 7) % n; sum++; } std::cout << sum + 1 << "\n"; } }
insert
14
14
14
18
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(v) (v).begin(), (v).end() #define debug(x) cerr << #x << ": " << (x) << endl #define INF (int)1e9 #define EPS (double)1e-9 #define MOD ((int)1e9 + 7) using namespace std; typedef long long llong; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef pair<int, int> pii; template <class Type> void line(const Type &a) { int cnt = 0; for (const auto &elem : a) { if (cnt++) cerr << ' '; cerr << elem; } cerr << endl; } int main() { int k; cin >> k; if (k % 2 == 0) { cout << -1 << endl; return 0; } int ans = 0; llong tmp = 0; while (1) { ans++; tmp = 10 * tmp + 7; tmp %= k; if (tmp == 0) break; } cout << ans << endl; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(v) (v).begin(), (v).end() #define debug(x) cerr << #x << ": " << (x) << endl #define INF (int)1e9 #define EPS (double)1e-9 #define MOD ((int)1e9 + 7) using namespace std; typedef long long llong; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef pair<int, int> pii; template <class Type> void line(const Type &a) { int cnt = 0; for (const auto &elem : a) { if (cnt++) cerr << ' '; cerr << elem; } cerr << endl; } int main() { int k; cin >> k; if (k % 2 == 0 or k % 5 == 0) { cout << -1 << endl; return 0; } int ans = 0; llong tmp = 0; while (1) { ans++; tmp = 10 * tmp + 7; tmp %= k; if (tmp == 0) break; } cout << ans << endl; }
replace
27
28
27
28
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; inline int read(void) { int num = 0, f = 1; char ch; while (!isdigit(ch = getchar())) if (ch == '-') f = -1; while (isdigit(ch)) num = num * 10 + ch - '0', ch = getchar(); return num * f; } int main() { int k = read(), n = 0, cnt = 0; if (!(k % 2)) puts("-1"); else while (true) { n = n * 10 + 7; cnt++; n %= k; if (!n) { printf("%d\n", cnt); break; } } return 0; }
#include <bits/stdc++.h> using namespace std; inline int read(void) { int num = 0, f = 1; char ch; while (!isdigit(ch = getchar())) if (ch == '-') f = -1; while (isdigit(ch)) num = num * 10 + ch - '0', ch = getchar(); return num * f; } int main() { int k = read(), n = 0, cnt = 0; if (!(k % 2)) puts("-1"); else while (true) { n = n * 10 + 7; cnt++; n %= k; if (!n) { printf("%d\n", cnt); break; } if (cnt > k) { puts("-1"); break; } } return 0; }
insert
25
25
25
29
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; int k; int main() { cin >> k; if (!(k & 1)) { cout << -1 << endl; return 0; } if (!(k % 7)) k /= 7; int a = 1, b = 1, n = 1; while (a % k) { ++n; b = b * 10 % k; a = (a + b) % k; } cout << n << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int k; int main() { cin >> k; if (!(k & 1) || !(k % 5)) { cout << -1 << endl; return 0; } if (!(k % 7)) k /= 7; int a = 1, b = 1, n = 1; while (a % k) { ++n; b = b * 10 % k; a = (a + b) % k; } cout << n << endl; }
replace
8
9
8
9
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll k; cin >> k; if (k % 2 == 0) { cout << "-1" << endl; return 0; } if (k % 7 == 0) { k = k / 7; } while (k % 10 == 0) { k = k / 10; } ll ans = 0; bool ok = true; ll tot = 1; while (ok) { if (tot % k == 0) { ans++; ok = false; break; } else { tot *= 10; tot += 1; tot %= k; ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll k; cin >> k; if (k % 2 == 0) { cout << "-1" << endl; return 0; } if (k % 7 == 0) { k = k / 7; } while (k % 10 == 0) { k = k / 10; } ll ans = 0; bool ok = true; ll tot = 1; while (ok) { if (ans >= 999983) { cout << -1 << endl; return 0; } if (tot % k == 0) { ans++; ok = false; break; } else { tot *= 10; tot += 1; tot %= k; ans++; } } cout << ans << endl; return 0; }
insert
21
21
21
25
TLE
p02596
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; void Main() { int K; cin >> K; if (7 % K == 0) { cout << 1 << endl; return; } int ans = -1; set<int> reminder; reminder.insert(7 % K); int n7 = 7; int pow10 = 10; int counter = 1; while (true) { ++counter; n7 += pow10 * 7; n7 %= K; if (n7 == 0) { ans = counter; break; } if (reminder.count(n7) > 0) { ans = -1; break; } pow10 *= 10; pow10 %= K; } cout << ans << endl; } int main() { std::cout << std::fixed << std::setprecision(15); Main(); return 0; }
#include "bits/stdc++.h" using namespace std; void Main() { int K; cin >> K; if (7 % K == 0) { cout << 1 << endl; return; } int ans = -1; set<int> reminder; reminder.insert(7 % K); int n7 = 7; int pow10 = 10; int counter = 1; while (true) { ++counter; n7 += pow10 * 7; n7 %= K; if (n7 == 0) { ans = counter; break; } if (reminder.count(n7) > 0) { ans = -1; break; } reminder.insert(n7); pow10 *= 10; pow10 %= K; } cout << ans << endl; } int main() { std::cout << std::fixed << std::setprecision(15); Main(); return 0; }
insert
31
31
31
32
TLE
p02596
C++
Time Limit Exceeded
#define LOCAL #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using ll = long long; using P = pair<int, int>; #define REP(i, x) for (int i = 0; i < (int)(x); i++) #define REPS(i, x) for (int i = 1; i <= (int)(x); i++) #define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--) #define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--) #define ALL(x) ((x).begin(), (x).end()) #define SIZE(x) ((int)(x).size()) #define BITS(x) (1LL << (x)) constexpr int INF = 1001001001; constexpr ll LINF = 1001001001001001001LL; constexpr int MOD = 1000000007; constexpr double EPS = 1e-10; constexpr double PI = 3.141592653589793; constexpr int dx[4] = {1, 0, -1, 0}; constexpr int dy[4] = {0, 1, 0, -1}; constexpr int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1}; constexpr int dy8[8] = {1, 0, -1, 1, -1, 1, 0, -1}; random_device seed_gen; mt19937 mrand(seed_gen()); mt19937_64 mrand64(seed_gen()); int rand32(int x) { return mrand() % x; } ll rand64(long x) { return mrand64() % x; } template <typename A, typename B> ostream &operator<<(ostream &out, const pair<A, B> &a) { out << "(" << a.first << "," << a.second << ")"; return out; } template <typename T, size_t N> ostream &operator<<(ostream &out, const array<T, N> &a) { out << "["; bool first = true; for (auto &v : a) { out << (first ? "" : ","); out << v; first = 0; } out << "]"; return out; } template <typename T> ostream &operator<<(ostream &out, const vector<T> &a) { out << "["; bool first = true; for (auto &v : a) { out << (first ? "" : ","); out << v; first = 0; } out << "]"; return out; } template <typename T, class Cmp> ostream &operator<<(ostream &out, const set<T, Cmp> &a) { out << "{"; bool first = true; for (auto &v : a) { out << (first ? "" : ","); out << v; first = 0; } out << "}"; return out; } template <typename U, typename T, class Cmp> ostream &operator<<(ostream &out, const map<U, T, Cmp> &a) { out << "{"; bool first = true; for (auto &p : a) { out << (first ? "" : ","); out << p.first << ": " << p.second; first = 0; } out << "}"; return out; } #ifdef LOCAL #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) #else #define trace(...) 42 #endif template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << ": " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << ": " << arg1 << " |"; __f(comma + 1, args...); } struct fast_ios { static constexpr int IOS_PREC = 15; static constexpr bool AUTOFLUSH = false; fast_ios() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(IOS_PREC); if (AUTOFLUSH) cout << unitbuf; } } fast_ios_; int main() { long k; cin >> k; if (~k & 1) { cout << -1 << endl; return 0; } long r = 7 % k; long ans = 1; while (r != 0) { r = (r * 10 + 7) % k; ans++; if (ans == 1e9) { cout << -1 << endl; return 0; } } cout << ans << endl; return 0; }
#define LOCAL #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using ll = long long; using P = pair<int, int>; #define REP(i, x) for (int i = 0; i < (int)(x); i++) #define REPS(i, x) for (int i = 1; i <= (int)(x); i++) #define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--) #define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--) #define ALL(x) ((x).begin(), (x).end()) #define SIZE(x) ((int)(x).size()) #define BITS(x) (1LL << (x)) constexpr int INF = 1001001001; constexpr ll LINF = 1001001001001001001LL; constexpr int MOD = 1000000007; constexpr double EPS = 1e-10; constexpr double PI = 3.141592653589793; constexpr int dx[4] = {1, 0, -1, 0}; constexpr int dy[4] = {0, 1, 0, -1}; constexpr int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1}; constexpr int dy8[8] = {1, 0, -1, 1, -1, 1, 0, -1}; random_device seed_gen; mt19937 mrand(seed_gen()); mt19937_64 mrand64(seed_gen()); int rand32(int x) { return mrand() % x; } ll rand64(long x) { return mrand64() % x; } template <typename A, typename B> ostream &operator<<(ostream &out, const pair<A, B> &a) { out << "(" << a.first << "," << a.second << ")"; return out; } template <typename T, size_t N> ostream &operator<<(ostream &out, const array<T, N> &a) { out << "["; bool first = true; for (auto &v : a) { out << (first ? "" : ","); out << v; first = 0; } out << "]"; return out; } template <typename T> ostream &operator<<(ostream &out, const vector<T> &a) { out << "["; bool first = true; for (auto &v : a) { out << (first ? "" : ","); out << v; first = 0; } out << "]"; return out; } template <typename T, class Cmp> ostream &operator<<(ostream &out, const set<T, Cmp> &a) { out << "{"; bool first = true; for (auto &v : a) { out << (first ? "" : ","); out << v; first = 0; } out << "}"; return out; } template <typename U, typename T, class Cmp> ostream &operator<<(ostream &out, const map<U, T, Cmp> &a) { out << "{"; bool first = true; for (auto &p : a) { out << (first ? "" : ","); out << p.first << ": " << p.second; first = 0; } out << "}"; return out; } #ifdef LOCAL #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) #else #define trace(...) 42 #endif template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << ": " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << ": " << arg1 << " |"; __f(comma + 1, args...); } struct fast_ios { static constexpr int IOS_PREC = 15; static constexpr bool AUTOFLUSH = false; fast_ios() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(IOS_PREC); if (AUTOFLUSH) cout << unitbuf; } } fast_ios_; int main() { long k; cin >> k; if (~k & 1) { cout << -1 << endl; return 0; } long r = 7 % k; long ans = 1; while (r != 0) { r = (r * 10 + 7) % k; ans++; if (ans == 1e8) { cout << -1 << endl; return 0; } } cout << ans << endl; return 0; }
replace
146
147
146
147
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define ll long long #define mk make_pair #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() void go() { int k; cin >> k; if (k % 2 == 0) { cout << "-1"; return; } int track = 0, ans = -1; for (int i = 0;; i++) { track = (track * 10 + 7) % k; if (track == 0) { ans = i + 1; break; } } cout << ans; } int main() { fastio(); go(); return 0; }
#include <bits/stdc++.h> using namespace std; #define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define ll long long #define mk make_pair #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() void go() { int k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << "-1"; return; } int track = 0, ans = -1; for (int i = 0;; i++) { track = (track * 10 + 7) % k; if (track == 0) { ans = i + 1; break; } } cout << ans; } int main() { fastio(); go(); return 0; }
replace
16
17
16
17
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vl; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<vl> vvl; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<pll> vpll; typedef vector<pii> vpii; typedef vector<vpll> vvpll; typedef vector<vpii> vvpii; #define pb push_back #define eb emplace_back #define pf push_front #define all(c) (c).begin(), (c).end() #define ff first #define ss second #define mp(x, y) make_pair((x), (y)) #define boost \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) void solve() { int k; cin >> k; bool rem[k]; memset(rem, false, sizeof(rem)); int n = 7; int cnt = 0; while (1) { cnt++; if (n % k == 0) { cout << cnt << '\n'; return; } if (rem[n % k]) { cout << -1 << '\n'; return; } n = (n * 10 + 7) % k; } } int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif boost; int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { // cout << "Case #" << i << ": "; solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vl; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<vl> vvl; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<pll> vpll; typedef vector<pii> vpii; typedef vector<vpll> vvpll; typedef vector<vpii> vvpii; #define pb push_back #define eb emplace_back #define pf push_front #define all(c) (c).begin(), (c).end() #define ff first #define ss second #define mp(x, y) make_pair((x), (y)) #define boost \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) void solve() { int k; cin >> k; bool rem[k]; memset(rem, false, sizeof(rem)); int n = 7; int cnt = 0; while (1) { cnt++; if (n % k == 0) { cout << cnt << '\n'; return; } if (rem[n % k]) { cout << -1 << '\n'; return; } rem[n % k] = true; n = (n * 10 + 7) % k; } } int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif boost; int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { // cout << "Case #" << i << ": "; solve(); } return 0; }
insert
46
46
46
47
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)n; i++) int main() { ll k; cin >> k; if (k % 2 == 0) { cout << "-1" << endl; return 0; } ll res = 1; ll x = 7; while (true) { x %= k; if (x == 0) { cout << res << endl; break; } res++; x *= 10; x += 7; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)n; i++) int main() { ll k; cin >> k; if (k % 2 == 0) { cout << "-1" << endl; return 0; } ll res = 1; ll x = 7; while (true) { if (res == 2000000) { cout << "-1" << endl; break; } x %= k; if (x == 0) { cout << res << endl; break; } res++; x *= 10; x += 7; } }
insert
16
16
16
20
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #ifdef _DEBUG #define dout cout #define debug() if (true) #define dvout(v) vout(v) #else #define dout \ if (false) \ cout #define debug() if (false) #define dvout(v) \ if (false) \ vout(v) #endif #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() #define vout(v) \ for (auto &i : v) { \ cout << i << " "; \ } \ cout << "\n"; // 配列出力 #define vec(v, n) vector<int> v(n, 0); #define vecll(v, n) vector<ll> v(n, 0); #define vecvec(v, n, m) vector<vector<int>> v(n, vector<int>(m)); #define vin(v) \ for (auto &i : v) \ cin >> i; // 配列入力 #define mod (int)(1e9 + 7) typedef long long ll; typedef unsigned long long ull; #define next asdnext #define prev asdprev #define _n "\n" #define _n2 "\n\n" #define _t "\t" // LLONG_MAX 9.2*1e18 9223372036854775807LL // O(1e7) O(1e8) void Main() { ll K; cin >> K; ll ans = 0; ll N = 0; for (ll i = 0; i <= 1e9; i++) { N = (N * 10 + 7) % K; // dout<<i<<':'<<N<<_n; if (N % K == 0) { cout << i + 1; return; } } cout << -1 << _n; } void Test(); int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << std::fixed << std::setprecision(15); Main(); return 0; }
#include <bits/stdc++.h> using namespace std; #ifdef _DEBUG #define dout cout #define debug() if (true) #define dvout(v) vout(v) #else #define dout \ if (false) \ cout #define debug() if (false) #define dvout(v) \ if (false) \ vout(v) #endif #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() #define vout(v) \ for (auto &i : v) { \ cout << i << " "; \ } \ cout << "\n"; // 配列出力 #define vec(v, n) vector<int> v(n, 0); #define vecll(v, n) vector<ll> v(n, 0); #define vecvec(v, n, m) vector<vector<int>> v(n, vector<int>(m)); #define vin(v) \ for (auto &i : v) \ cin >> i; // 配列入力 #define mod (int)(1e9 + 7) typedef long long ll; typedef unsigned long long ull; #define next asdnext #define prev asdprev #define _n "\n" #define _n2 "\n\n" #define _t "\t" // LLONG_MAX 9.2*1e18 9223372036854775807LL // O(1e7) O(1e8) void Main() { ll K; cin >> K; ll ans = 0; ll N = 0; for (ll i = 0; i <= 1e8; i++) { N = (N * 10 + 7) % K; // dout<<i<<':'<<N<<_n; if (N % K == 0) { cout << i + 1; return; } } cout << -1 << _n; } void Test(); int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << std::fixed << std::setprecision(15); Main(); return 0; }
replace
49
50
49
50
TLE
p02596
C++
Runtime Error
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; int main() { ll k; ll a = 7; for (int i = 0; i <= k; i++) { if (a % k == 0) { cout << i + 1 << endl; return 0; } a = (a * 10 + 7) % k; } cout << -1 << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; int main() { ll k; cin >> k; ll a = 7; for (int i = 0; i <= k; i++) { if (a % k == 0) { cout << i + 1 << endl; return 0; } a = (a * 10 + 7) % k; } cout << -1 << endl; return 0; }
insert
19
19
19
20
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int sum[500005]; int vis[500005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, i, j = 0; cin >> n; if (n % 2 == 0) { cout << -1 << endl; } else { long long p = 7 % n; j++; while (p != 0) { p = (p * 10 + 7) % n; j++; } cout << j << endl; } }
#include <bits/stdc++.h> using namespace std; int sum[500005]; int vis[500005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, i, j = 0; cin >> n; if (n % 2 == 0 || n % 5 == 0) { cout << -1 << endl; } else { long long p = 7 % n; j++; while (p != 0) { p = (p * 10 + 7) % n; j++; } cout << j << endl; } }
replace
10
11
10
11
TLE
p02596
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int k; cin >> k; if (k % 2 == 0) return cout << -1, 0; string s = "7"; long long cur_power = 1, cur = 7; while (cur % k != 0) { cur_power = cur_power * 10 % k; cur = cur + 7 * cur_power % k; cur %= k; s += '7'; } cout << s.size(); }
#include <iostream> using namespace std; int main() { int k; cin >> k; if (k % 2 == 0) return cout << -1, 0; string s = "7"; long long cur_power = 1, cur = 7; while (cur % k != 0) { cur_power = cur_power * 10 % k; cur = cur + 7 * cur_power % k; cur %= k; s += '7'; if (s.size() > k) return cout << -1, 0; } cout << s.size(); }
insert
15
15
15
17
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; /*helpfull*/ using vl = vector<long long>; using vpl = vector<pair<long long, long long>>; using vs = vector<string>; using pl = pair<long long, long long>; using ll = long long int; using vb = vector<bool>; struct hash_pair { template <class T1, class T2> size_t operator()(const pair<T1, T2> &p) const { auto hash1 = hash<T1>{}(p.first); auto hash2 = hash<T2>{}(p.second); return hash1 ^ hash2; } }; // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif // shortcut macros #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define mp make_pair #define fi first #define se second // #define mt make_tuple #define pb push_back #define all(x) (x).begin(), (x).end() #define ini(a, v) memset(a, v, sizeof(a)) #define rep(i, a, n) for (ll i = a; i < n; ++i) #define For(i, n) rep(i, 0, n) #define sz(x) (int((x).size())) #define ump(x, y) unordered_map<x, y> #define umpr(x, y, z) unordered_map<x, y, z> void printcase(ll &x) { cout << "Case #" << x << ": "; } void read(vector<ll> &v, ll &n) { For(i, n) cin >> v[i]; } void read(ll &x) { cin >> x; } void read(string &s) { cin >> s; } void read(int &x) { cin >> x; } void read(ll a[], ll &n) { For(i, n) cin >> a[i]; } void print() { cout << endl; } void write(vector<ll> &v, ll &n) { For(i, n) cout << v[i] << " "; cout << endl; } void write(vector<ll> &v) { ll n = v.size(); For(i, n) cout << v[i] << " "; cout << endl; } void write(ll x) { cout << x << endl; } void write(string &s) { cout << s << endl; } void write(int &x) { cout << x << endl; } void write(ll a[], ll &n) { For(i, n) cout << a[i] << " "; cout << endl; } // ll solve() { // ll n, k; // cin >> n >> k; // vl v(n); // read(v, n); // if (k == 0) // return *max_element(all(v)); // sort(all(v)); // vector<ll > d(n, k / n); // for (int i = 0; i < n; i++) { // } ll solve(ll k) { ll i = 0; ll c = 0; ll n = 1e9; ll prev = -1; while (n--) { ++c; i = (i * 10 + 7) % k; if (i == prev) return -1; if (i == 0) return c; prev = i; } return -1; } // return 1; // } int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif IOS; ll k; cin >> k; cout << solve(k) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; /*helpfull*/ using vl = vector<long long>; using vpl = vector<pair<long long, long long>>; using vs = vector<string>; using pl = pair<long long, long long>; using ll = long long int; using vb = vector<bool>; struct hash_pair { template <class T1, class T2> size_t operator()(const pair<T1, T2> &p) const { auto hash1 = hash<T1>{}(p.first); auto hash2 = hash<T2>{}(p.second); return hash1 ^ hash2; } }; // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif // shortcut macros #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define mp make_pair #define fi first #define se second // #define mt make_tuple #define pb push_back #define all(x) (x).begin(), (x).end() #define ini(a, v) memset(a, v, sizeof(a)) #define rep(i, a, n) for (ll i = a; i < n; ++i) #define For(i, n) rep(i, 0, n) #define sz(x) (int((x).size())) #define ump(x, y) unordered_map<x, y> #define umpr(x, y, z) unordered_map<x, y, z> void printcase(ll &x) { cout << "Case #" << x << ": "; } void read(vector<ll> &v, ll &n) { For(i, n) cin >> v[i]; } void read(ll &x) { cin >> x; } void read(string &s) { cin >> s; } void read(int &x) { cin >> x; } void read(ll a[], ll &n) { For(i, n) cin >> a[i]; } void print() { cout << endl; } void write(vector<ll> &v, ll &n) { For(i, n) cout << v[i] << " "; cout << endl; } void write(vector<ll> &v) { ll n = v.size(); For(i, n) cout << v[i] << " "; cout << endl; } void write(ll x) { cout << x << endl; } void write(string &s) { cout << s << endl; } void write(int &x) { cout << x << endl; } void write(ll a[], ll &n) { For(i, n) cout << a[i] << " "; cout << endl; } // ll solve() { // ll n, k; // cin >> n >> k; // vl v(n); // read(v, n); // if (k == 0) // return *max_element(all(v)); // sort(all(v)); // vector<ll > d(n, k / n); // for (int i = 0; i < n; i++) { // } ll solve(ll k) { ll i = 0; ll c = 0; ll n = 1e8; ll prev = -1; while (n--) { ++c; i = (i * 10 + 7) % k; if (i == prev) return -1; if (i == 0) return c; prev = i; } return -1; } // return 1; // } int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif IOS; ll k; cin >> k; cout << solve(k) << endl; return 0; }
replace
83
84
83
84
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { ll k; ll count = 0; ll amount = 0; ll ans = -1; cin >> k; if (k % 2 == 0) { cout << ans << endl; } else { for (;;) { amount *= 10; amount += 7; count++; if (amount % k == 0) { ans = count; break; } else { amount = amount % k; } } cout << ans << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { ll k; ll count = 0; ll amount = 0; ll ans = -1; cin >> k; if (k % 2 == 0) { cout << ans << endl; } else { rep(i, 1e7) { amount *= 10; amount += 7; count++; if (amount % k == 0) { ans = count; break; } else { amount = amount % k; } } cout << ans << endl; } }
replace
14
15
14
15
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; if ((k % 2) == 0 || (k % 5) == 0) cout << -1 << endl; else if (k == 1) cout << 1 << endl; else { if ((k % 7) == 0) k /= 7; vector<int> x(0); x.push_back(1 % k); while (1) { int X = (10 * x.at(x.size() - 1)) % k; if (X == 1) break; x.push_back(X); } int c = 0, m = 0; bool b = 0; while (1) { for (int X : x) { c++; m += X; m = m % k; if (m == 0) { b = 1; break; } } if (b) break; } cout << c << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; if ((k % 2) == 0 || (k % 5) == 0) cout << -1 << endl; else if (k == 1 || k == 7) cout << 1 << endl; else { if ((k % 7) == 0) k /= 7; vector<int> x(0); x.push_back(1 % k); while (1) { int X = (10 * x.at(x.size() - 1)) % k; if (X == 1) break; x.push_back(X); } int c = 0, m = 0; bool b = 0; while (1) { for (int X : x) { c++; m += X; m = m % k; if (m == 0) { b = 1; break; } } if (b) break; } cout << c << endl; } }
replace
8
9
8
9
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) \ ; \ for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> state; long double pi = acos(-1); const int INF = 1001001001; // 最小公倍数を求める int euqlid(int a, int b) { int temp; temp = a % b; if (temp == 0) return b; return euqlid(b, temp); } ll conbination(ll a, ll b) { ll u = 1; ll d = 1; while (b != 0) { u *= a; d *= b; a--; b--; } return u / d; } int strtoint(char s) { return (int(s - '0')); } char changeS(char alpha) { if (0x41 <= alpha and alpha <= 0x5A) return (alpha + 0x20); else if (0x61 <= alpha and alpha <= 0x7A) return (alpha - 0x20); return alpha; } int fact(int n) { if (n == 1) return 1; return n * fact(n - 1); } int ceil(int a, int b) { // a/bの切り上げを考える return (a + b - 1) / b; } int main() { int k; cin >> k; int ans = -1; if (k % 2 == 0) { cout << ans << endl; return 0; } int seven = 7; int cnt = 1; seven %= k; while (1) { if (seven == 0) break; else { seven = (7 + seven * 10) % k; cnt++; } } cout << cnt << endl; }
#include <bits/stdc++.h> #define rep(i, n) \ ; \ for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> state; long double pi = acos(-1); const int INF = 1001001001; // 最小公倍数を求める int euqlid(int a, int b) { int temp; temp = a % b; if (temp == 0) return b; return euqlid(b, temp); } ll conbination(ll a, ll b) { ll u = 1; ll d = 1; while (b != 0) { u *= a; d *= b; a--; b--; } return u / d; } int strtoint(char s) { return (int(s - '0')); } char changeS(char alpha) { if (0x41 <= alpha and alpha <= 0x5A) return (alpha + 0x20); else if (0x61 <= alpha and alpha <= 0x7A) return (alpha - 0x20); return alpha; } int fact(int n) { if (n == 1) return 1; return n * fact(n - 1); } int ceil(int a, int b) { // a/bの切り上げを考える return (a + b - 1) / b; } int main() { int k; cin >> k; int ans = -1; if (k % 2 == 0) { cout << ans << endl; return 0; } int seven = 7; int cnt = 1; seven %= k; while (1) { if (seven == 0) break; else { seven = (7 + seven * 10) % k; cnt++; } if (cnt > k) { cout << ans << endl; return 0; } } cout << cnt << endl; }
insert
67
67
67
71
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, k; int count = 1; cin >> n; k = 7; long long int sum = 7; if (n % 2 == 0 || n == 5) { cout << "-1\n"; return 0; } while (sum % n != 0) { sum = sum + ((k % n) * (10 % n)) % n; k = ((k % n) * (10 % n)); count++; } cout << count << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, k; int count = 1; cin >> n; k = 7; long long int sum = 7; if (n % 2 == 0 || n % 5 == 0) { cout << "-1\n"; return 0; } while (sum % n != 0) { sum = sum + ((k % n) * (10 % n)) % n; k = ((k % n) * (10 % n)); count++; } cout << count << "\n"; }
replace
10
11
10
11
TLE
p02596
C++
Time Limit Exceeded
// author-Shivam gupta #include <bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, (b), sizeof(a)) #define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++) #define IN(A, B, C) assert(B <= A && A <= C) #define MP make_pair #define FOR(i, a) for (int i = 0; i < a; i++) #define FOR1(i, j, a) for (int i = j; i < a; i++) #define EB emplace_back #define INF (int)1e9 #define EPS 1e-9 #define PI 3.1415926535897932384626433832795 #define MOD 1000000007 #define read(type) readInt<type>() #define max1 100001 #define out(x) cout << x << '\n' #define out1(x) cout << x << " " #define END cout << '\n' #define int long long void fast() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } signed main() { int n; cin >> n; if (n % 2 == 0) { out(-1); return 0; } int x = 0; int p = n; int cnt = 0; while (p > 0) { x *= 10; x += 7; p = p / 10; cnt++; } if (x < n) { x *= 10; x += 7; cnt++; } int a = x % n; if (a == 0) { out(cnt); return 0; } p = a; while (p < n) { p *= 10; p += 7; cnt++; } while (1) { a = p % n; if (a == 0) { out(cnt); return 0; } p = a; while (p < n) { p *= 10; p += 7; cnt++; } } out(-1); }
// author-Shivam gupta #include <bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, (b), sizeof(a)) #define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++) #define IN(A, B, C) assert(B <= A && A <= C) #define MP make_pair #define FOR(i, a) for (int i = 0; i < a; i++) #define FOR1(i, j, a) for (int i = j; i < a; i++) #define EB emplace_back #define INF (int)1e9 #define EPS 1e-9 #define PI 3.1415926535897932384626433832795 #define MOD 1000000007 #define read(type) readInt<type>() #define max1 100001 #define out(x) cout << x << '\n' #define out1(x) cout << x << " " #define END cout << '\n' #define int long long void fast() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } signed main() { int n; cin >> n; if (n % 2 == 0) { out(-1); return 0; } int x = 0; int p = n; int cnt = 0; while (p > 0) { x *= 10; x += 7; p = p / 10; cnt++; } if (x < n) { x *= 10; x += 7; cnt++; } int a = x % n; if (a == 0) { out(cnt); return 0; } p = a; while (p < n) { p *= 10; p += 7; cnt++; } int w = 1000000; while (w--) { a = p % n; if (a == 0) { out(cnt); return 0; } p = a; while (p < n) { p *= 10; p += 7; cnt++; } } out(-1); }
replace
72
73
72
74
TLE
p02596
C++
Runtime Error
#include <bits/stdc++.h> #include <cctype> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int #define ld long double #define PRY cout << "YES\n" #define PRN cout << "NO\n" #define SETP(sp) fixed << setprecision(sp) #define PB push_back #define GO \ ll t; \ cin >> t; \ while (t--) #define G(t) \ cin >> t; \ while (t--) #define ALLR(x) x.rbegin(), x.rend() #define PII pair<ll, ll> #define VI vector<ll> #define ALL(a) (a).begin(), (a).end() #define F first #define S second #define PI 3.141592653589793238 #define SZ(x) (ll) x.size() #define hell9 998244353 #define hell 1e9 + 7 #define FO(i, a, b) for (i = a; i < b; i++) #define FOREV(i, a, b) for (i = a; i >= b; i--) #define lbnd lower_bound #define ubnd upper_bound #define BS binary_search #define MP make_pair #define LIM 100005 #define ARR(n, i, a) \ ll n, i; \ cin >> n; \ ll a[n]; \ FO(i, 0, n) cin >> a[i]; #define ARRK(k, n, i, a) \ int n, k, i; \ scanf("%d%d", &n, &k); \ ll a[n]; \ FO(i, 0, n) scanf("%lld", &a[i]); #define fio \ ios_base::sync_with_stdio(false); \ cin.tie(0); using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ord_set; /*ll powM(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }/* ll POW(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res * x); y = y >> 1; x = (x * x); } return res; } int LIS(std::vector<int>& v) { if (v.size() == 0) return 0; std::vector<int> tail(v.size(), 0); int length = 1; tail[0] = v[0]; for (int i = 1; i < v.size(); i++) { auto b = tail.begin(), e = tail.begin() + length; auto it = lower_bound(b, e, v[i]); if (it == tail.begin() + length) tail[length++] = v[i]; else *it = v[i]; } return length; } ll modInverse(ll n, ll p) { return powM(n, p - 2, p); } /* ll fac[500000] = {0}; ll done = 1; ncrModP(ll n, ll r, ll p) { if (r == 0) return 1; fac[0] = 1; if (n > done) { for (ll i = done ; i <= n; i++) fac[i] = (fac[i - 1] * i) % p; } done = max(done, n); return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; } ll ncrM(ll n, ll r) { if (r > n - r) r = n - r; ll C[r + 1]; memset(C, 0, sizeof(C)); C[0] = 1; for (ll i = 1; i <= n; i++) { for (ll j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]); } return C[r]; } map<ll, ll>f; ll fib(ll k) { ll i; f[0] = 1; f[1] = 1; f[2] = 2; if (k <= done)return f[k]; for (i = done; i <= k; i++)f[i] = (f[i - 1] % hell + f[i - 2] % hell) % hell; done = k; return f[k] % hell; }void sieve(int n) { bool prime[5*LIM]; memset(prime, true, sizeof(prime)); int rootn = (int)sqrt(n); for (int p = 2; p <= rootn; p++) if (prime[p] == true) for (int i = p*p; i <= n; i += p) prime[i] = false; prime[1] = 0; } bool sortinrev(const pair<int,int> &a, const pair<int,int> &b) { if(a.first!=b.first) return (a.first > b.first); else return (a.second<b.second); } int x[101]; int y[101]; bool vis[200005]={0}; int n; int a[200005]={0}; vector<int> b[200005]; int p[200005]={0}; vector<pair<int,int> > a1,a2; map<pair<int,int>,int >m; char gr[51][51]; int n,c=0; void dfs(int u,int v) { if(u<0||u>=n||v<0||v>=n)return; if(m[{u,v}]!=0)return; if(gr[u][v]=='1')return; m[{u,v}]=c; if(c==1)a1.PB({u,v}); if(c==2)a2.PB({u,v}); dfs(u-1,v); dfs(u+1,v); dfs(u,v-1); dfs(u,v+1); }*/ int t; int main() { fio int k, j = 7, i = 1, f = 0; while (i <= 1000000) { if (j % k == 0) { f = 1; break; } j = ((j * 10) % k + 7) % k; i++; } if (f == 1) cout << i; else cout << -1; return 0; }
#include <bits/stdc++.h> #include <cctype> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int #define ld long double #define PRY cout << "YES\n" #define PRN cout << "NO\n" #define SETP(sp) fixed << setprecision(sp) #define PB push_back #define GO \ ll t; \ cin >> t; \ while (t--) #define G(t) \ cin >> t; \ while (t--) #define ALLR(x) x.rbegin(), x.rend() #define PII pair<ll, ll> #define VI vector<ll> #define ALL(a) (a).begin(), (a).end() #define F first #define S second #define PI 3.141592653589793238 #define SZ(x) (ll) x.size() #define hell9 998244353 #define hell 1e9 + 7 #define FO(i, a, b) for (i = a; i < b; i++) #define FOREV(i, a, b) for (i = a; i >= b; i--) #define lbnd lower_bound #define ubnd upper_bound #define BS binary_search #define MP make_pair #define LIM 100005 #define ARR(n, i, a) \ ll n, i; \ cin >> n; \ ll a[n]; \ FO(i, 0, n) cin >> a[i]; #define ARRK(k, n, i, a) \ int n, k, i; \ scanf("%d%d", &n, &k); \ ll a[n]; \ FO(i, 0, n) scanf("%lld", &a[i]); #define fio \ ios_base::sync_with_stdio(false); \ cin.tie(0); using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ord_set; /*ll powM(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }/* ll POW(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res * x); y = y >> 1; x = (x * x); } return res; } int LIS(std::vector<int>& v) { if (v.size() == 0) return 0; std::vector<int> tail(v.size(), 0); int length = 1; tail[0] = v[0]; for (int i = 1; i < v.size(); i++) { auto b = tail.begin(), e = tail.begin() + length; auto it = lower_bound(b, e, v[i]); if (it == tail.begin() + length) tail[length++] = v[i]; else *it = v[i]; } return length; } ll modInverse(ll n, ll p) { return powM(n, p - 2, p); } /* ll fac[500000] = {0}; ll done = 1; ncrModP(ll n, ll r, ll p) { if (r == 0) return 1; fac[0] = 1; if (n > done) { for (ll i = done ; i <= n; i++) fac[i] = (fac[i - 1] * i) % p; } done = max(done, n); return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; } ll ncrM(ll n, ll r) { if (r > n - r) r = n - r; ll C[r + 1]; memset(C, 0, sizeof(C)); C[0] = 1; for (ll i = 1; i <= n; i++) { for (ll j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]); } return C[r]; } map<ll, ll>f; ll fib(ll k) { ll i; f[0] = 1; f[1] = 1; f[2] = 2; if (k <= done)return f[k]; for (i = done; i <= k; i++)f[i] = (f[i - 1] % hell + f[i - 2] % hell) % hell; done = k; return f[k] % hell; }void sieve(int n) { bool prime[5*LIM]; memset(prime, true, sizeof(prime)); int rootn = (int)sqrt(n); for (int p = 2; p <= rootn; p++) if (prime[p] == true) for (int i = p*p; i <= n; i += p) prime[i] = false; prime[1] = 0; } bool sortinrev(const pair<int,int> &a, const pair<int,int> &b) { if(a.first!=b.first) return (a.first > b.first); else return (a.second<b.second); } int x[101]; int y[101]; bool vis[200005]={0}; int n; int a[200005]={0}; vector<int> b[200005]; int p[200005]={0}; vector<pair<int,int> > a1,a2; map<pair<int,int>,int >m; char gr[51][51]; int n,c=0; void dfs(int u,int v) { if(u<0||u>=n||v<0||v>=n)return; if(m[{u,v}]!=0)return; if(gr[u][v]=='1')return; m[{u,v}]=c; if(c==1)a1.PB({u,v}); if(c==2)a2.PB({u,v}); dfs(u-1,v); dfs(u+1,v); dfs(u,v-1); dfs(u,v+1); }*/ int t; int main() { fio int k, j = 7, i = 1, f = 0; cin >> k; while (i <= 1000000) { if (j % k == 0) { f = 1; break; } j = ((j * 10) % k + 7) % k; i++; } if (f == 1) cout << i; else cout << -1; return 0; }
insert
185
185
185
186
0
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define ll long long #define REP(i, n) for (int i = 0; i < n; i++) #define PI 3.141592653589 #define MOD 1000000007 using namespace std; template <typename T> T gcd(T a, T b) { return (a % b) ? gcd(b, a % b) : b; } template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); } int main(void) { ll k; cin >> k; if (k % 2 == 0) { cout << -1 << endl; } else { int i = 1; ll rem = 0; ll num = 7; while (1) { num = num % k; rem += num; if (rem % k == 0) { cout << i << endl; break; } num *= 10; i++; } } return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define ll long long #define REP(i, n) for (int i = 0; i < n; i++) #define PI 3.141592653589 #define MOD 1000000007 using namespace std; template <typename T> T gcd(T a, T b) { return (a % b) ? gcd(b, a % b) : b; } template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); } int main(void) { ll k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; } else { int i = 1; ll rem = 0; ll num = 7; while (1) { num = num % k; rem += num; if (rem % k == 0) { cout << i << endl; break; } num *= 10; i++; } } return 0; }
replace
22
23
22
23
TLE
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <vector> using ll = long long; using namespace std; int main() { long a = 0; long K; cin >> K; if (K % 7 == 0) K /= 7; if (K % 2 == 0) { cout << -1; exit(0); } long n = 1; long r = 1 % K; while (r != 0) { r = (10 * r + 1) % K; n += 1; } cout << n; return 0; }
#include <algorithm> #include <iostream> #include <vector> using ll = long long; using namespace std; int main() { long a = 0; long K; cin >> K; if (K % 7 == 0) K /= 7; if (K % 2 == 0 || K % 5 == 0) { cout << -1; exit(0); } long n = 1; long r = 1 % K; while (r != 0) { r = (10 * r + 1) % K; n += 1; } cout << n; return 0; }
replace
13
14
13
14
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int k, L; cin >> k; if (k % 7 == 0) k /= 7; L = 9 * k; if (L == 2 || L == 5) { cout << -1 << '\n'; return 0; } int tmp = 10, cnt = 1; while (1) { if (tmp % L == 1) { cout << cnt << '\n'; return 0; } tmp %= L; tmp *= 10; cnt++; } }
#include <bits/stdc++.h> using namespace std; int main() { int k, L; cin >> k; if (k % 7 == 0) k /= 7; L = 9 * k; if (L % 2 == 0 || L % 5 == 0) { cout << -1 << '\n'; return 0; } int tmp = 10, cnt = 1; while (1) { if (tmp % L == 1) { cout << cnt << '\n'; return 0; } tmp %= L; tmp *= 10; cnt++; } }
replace
10
11
10
11
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main(void) { long long k; cin >> k; long long tmp = 7 % k; set<int> s; s.insert(7); if (tmp == 0) { cout << 1 << endl; return 0; } s.insert(tmp); for (long long i = 2;; i++) { tmp = ((tmp * 10) % k + 7 % k) % k; if (tmp == 0) { cout << i << endl; return 0; } if (s.find(tmp) != s.end()) { cout << -1 << endl; return 0; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { long long k; cin >> k; long long tmp = 7 % k; set<int> s; s.insert(7); if (tmp == 0) { cout << 1 << endl; return 0; } s.insert(tmp); for (long long i = 2;; i++) { tmp = ((tmp * 10) % k + 7 % k) % k; if (tmp == 0) { cout << i << endl; return 0; } if (s.find(tmp) != s.end()) { cout << -1 << endl; return 0; } s.insert(tmp); } return 0; }
insert
24
24
24
25
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long int #define ld long double #define inf LLONG_MAX >> 2 #define MAX 1000000 #define mod 1000000007 #define pb push_back #define f(i, a, n, x) for ((i) = (a); (i) < (n); (i) += (x)) #define fd(i, a, n, x) for ((i) = (a); (i) >= (n); (i) -= (x)) #define fi first #define se second #define mk make_pair #define pi pair #define vt vector #define ms multiset using namespace std; void read(vt<ll> &a, ll n) { ll i, temp; f(i, 0, n, 1) { cin >> temp; a.pb(temp); } } ll fa[MAX]; ll power(ll p, ll q) { ll res = 1; p %= mod; while (q) { if (q & 1) res = (res * p) % mod; q >>= 1; p = (p * p) % mod; } return res; } ll fact(ll n) { if (n <= 1) return fa[n] = 1; if (fa[n]) return fa[n]; return fa[n] = (n * fact(n - 1)) % mod; } ll ncr(ll n, ll r) { if (!r) return 1; return (((fact(n) * power(fact(n - r), mod - 2)) % mod) * power(fact(r), mod - 2)) % mod; } void solve() { ll n = 7, k, count = 1; cin >> k; while (count <= 100000000) { if (!(n % k)) { cout << count << endl; return; } n = (((n % k) * 10) % k + 7) % k; count++; } cout << -1 << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll t = 1; // cin>>t; while (t--) solve(); return 0; }
#include <bits/stdc++.h> #define ll long long int #define ld long double #define inf LLONG_MAX >> 2 #define MAX 1000000 #define mod 1000000007 #define pb push_back #define f(i, a, n, x) for ((i) = (a); (i) < (n); (i) += (x)) #define fd(i, a, n, x) for ((i) = (a); (i) >= (n); (i) -= (x)) #define fi first #define se second #define mk make_pair #define pi pair #define vt vector #define ms multiset using namespace std; void read(vt<ll> &a, ll n) { ll i, temp; f(i, 0, n, 1) { cin >> temp; a.pb(temp); } } ll fa[MAX]; ll power(ll p, ll q) { ll res = 1; p %= mod; while (q) { if (q & 1) res = (res * p) % mod; q >>= 1; p = (p * p) % mod; } return res; } ll fact(ll n) { if (n <= 1) return fa[n] = 1; if (fa[n]) return fa[n]; return fa[n] = (n * fact(n - 1)) % mod; } ll ncr(ll n, ll r) { if (!r) return 1; return (((fact(n) * power(fact(n - r), mod - 2)) % mod) * power(fact(r), mod - 2)) % mod; } void solve() { ll n = 7, k, count = 1; cin >> k; while (count <= 10000000) { if (!(n % k)) { cout << count << endl; return; } n = (((n % k) * 10) % k + 7) % k; count++; } cout << -1 << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll t = 1; // cin>>t; while (t--) solve(); return 0; }
replace
52
53
52
53
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ull = unsigned long long; using ll = long long; int main() { int k; cin >> k; ll a = 7 % k; ll b = 7; if (a == 0) { cout << 1 << endl; return 0; } if (b % 2 == 0 || b % 5 == 0) { cout << -1 << endl; return 0; } for (int n = 2;; n++) { b = (b * 10) % k; a = (a + b) % k; if (a == 0) { cout << n << endl; break; } } }
#include <bits/stdc++.h> using namespace std; using ull = unsigned long long; using ll = long long; int main() { int k; cin >> k; ll a = 7 % k; ll b = 7; if (a == 0) { cout << 1 << endl; return 0; } if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; return 0; } for (int n = 2;; n++) { b = (b * 10) % k; a = (a + b) % k; if (a == 0) { cout << n << endl; break; } } }
replace
16
17
16
17
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ll n, x = 7, ans = 1; cin >> n; if ((n % 2) == 0) { cout << "-1\n"; return 0; } while (true) { if ((x % n) == 0) { cout << ans << '\n'; return 0; } x *= 10; x += 7; x %= n; ans++; } }
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ll n, x = 7, ans = 1; cin >> n; if ((n % 2) == 0) { cout << "-1\n"; return 0; } while (true) { if ((x % n) == 0) { cout << ans << '\n'; return 0; } x *= 10; x += 7; x %= n; ans++; if (ans > 1000001) { cout << -1 << '\n'; return 0; } } }
insert
21
21
21
25
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long #define rep(A, B, C) for (A = B; A < C; ++A) #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; ///////////////////////////////////////////////////// ll K; ll i, j, k; int main() { scanf("%lld", &K); if (K % 2 == 0) { printf("-1\n"); return 0; } i = 0; do { (k = k * 10 + 7) %= K; ++i; } while (k); printf("%lld\n", i); return 0; }
#include <bits/stdc++.h> #define ll long long #define rep(A, B, C) for (A = B; A < C; ++A) #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; ///////////////////////////////////////////////////// ll K; ll i, j, k; int main() { scanf("%lld", &K); if (K % 2 == 0 || K % 5 == 0) { printf("-1\n"); return 0; } i = 0; do { (k = k * 10 + 7) %= K; ++i; } while (k); printf("%lld\n", i); return 0; }
replace
17
18
17
18
TLE
p02596
C++
Time Limit Exceeded
#pragma GCC optimize(2) #include <bits/stdc++.h> namespace __temp_inbuilt { int read(void) { int res = 0, sign = 1; char ch = std::getchar(); while (!std::isdigit(ch)) { if (ch == '-') sign = -1; ch = std::getchar(); } while (std::isdigit(ch)) res = res * 10 + ch - 48, ch = std::getchar(); return sign * res; } template <class Tp> void write(const Tp &x) { if (x > 9) write(x / 10); std::putchar(x % 10 + 48); } } // namespace __temp_inbuilt using __temp_inbuilt::read; template <class Tp> void writeln(const Tp &x) { if (x < 0) std::putchar('-'); __temp_inbuilt::write(x > 0 ? x : -x); std::putchar('\n'); } template <class Tp> void writesp(const Tp &x) { if (x < 0) std::putchar('-'); __temp_inbuilt::write(x > 0 ? x : -x); std::putchar(' '); } template <class Tp> void write(const Tp &x) { if (x < 0) std::putchar('-'); __temp_inbuilt::write(x > 0 ? x : -x); } typedef long long ll; typedef unsigned long long ull; typedef double rl; typedef long double RL; const rl PI = 3.1415926535898, E = 2.71828182845904; namespace contest { int k; int main() { k = read(); int mod = 7 % k, ans = 1; if (!mod) { writeln(ans); return 0; } while (mod) { ++ans; mod = (mod * 10 + 7) % k; if (mod == 7 % k) { writeln(-1); return 0; } } writeln(ans); return 0; return 0; } } // namespace contest int main() { contest::main(); return 0; }
#pragma GCC optimize(2) #include <bits/stdc++.h> namespace __temp_inbuilt { int read(void) { int res = 0, sign = 1; char ch = std::getchar(); while (!std::isdigit(ch)) { if (ch == '-') sign = -1; ch = std::getchar(); } while (std::isdigit(ch)) res = res * 10 + ch - 48, ch = std::getchar(); return sign * res; } template <class Tp> void write(const Tp &x) { if (x > 9) write(x / 10); std::putchar(x % 10 + 48); } } // namespace __temp_inbuilt using __temp_inbuilt::read; template <class Tp> void writeln(const Tp &x) { if (x < 0) std::putchar('-'); __temp_inbuilt::write(x > 0 ? x : -x); std::putchar('\n'); } template <class Tp> void writesp(const Tp &x) { if (x < 0) std::putchar('-'); __temp_inbuilt::write(x > 0 ? x : -x); std::putchar(' '); } template <class Tp> void write(const Tp &x) { if (x < 0) std::putchar('-'); __temp_inbuilt::write(x > 0 ? x : -x); } typedef long long ll; typedef unsigned long long ull; typedef double rl; typedef long double RL; const rl PI = 3.1415926535898, E = 2.71828182845904; namespace contest { int k; int main() { k = read(); int mod = 7 % k, ans = 1; if (!mod) { writeln(ans); return 0; } while (mod) { ++ans; mod = (mod * 10 + 7) % k; if (mod == 7 % k || ans >= 3e7) { writeln(-1); return 0; } } writeln(ans); return 0; return 0; } } // namespace contest int main() { contest::main(); return 0; }
replace
66
67
66
67
TLE
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; int main() { ll K, sev = 0, rep = 0; cin >> K; if (K % 2 == 0) { cout << -1 << endl; return 0; } while (sev <= K) { sev = sev * 10 + 7; sev = sev % K; rep++; if (sev == 0) { cout << rep << endl; return 0; } } cout << -1 << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; int main() { ll K, sev = 0, rep = 0; cin >> K; if (K % 2 == 0) { cout << -1 << endl; return 0; } while (rep <= K) { sev = sev * 10 + 7; sev = sev % K; rep++; if (sev == 0) { cout << rep << endl; return 0; } } cout << -1 << endl; }
replace
17
18
17
18
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define fi first #define se second #define pb push_back #define mp make_pair #define fo(i, n) for (i = 0; i < n; i++) #define fo1(i, n) for (i = 1; i <= n; i++) #define foab(i, a, b) for (i = a; i <= b; i++) #define of(i, n) for (i = n - 1; i >= 0; i--) #define of1(i, n) for (i = n; i >= 1; i--) #define ofab(i, a, b) for (i = a; i >= b; i--) #define sq(a) (a) * (a) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sortall(x) sort(all(x)) #define sortrall(x) sort(rall(x)) #define clr(x) memset(x, 0, sizeof(x)) #define tr(it, a) for (auto it = a.begin(); it != a.end(); it++) #define pii pair<int, int> #define mk(arr, n, type) type *arr = new type[n]; #define vi vector<int> #define si set<int> #define usi unordered_set<int> #define mii map<int, int> #define umii unordered_map<int, int> #define pqmx priority_queue<int> #define pqmn priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcountll(x) #define trailzrobits(x) __builtin_ctzll(x) #define leadzrobits(x) __builtin_clzll(x) #define paritybits(x) __builtin_parityll(x) #define gcd __gcd #define lcm(x, y) (x * y) / gcd(x, y) #define endl '\n' #define sz(s) (int)s.size() #define sp(x, y) fixed << setprecision(y) << x const int mod = 1000000007; const int inf = 1000000000000000000; const ld PI = 3.1415926535897932384626; const ld eps = 1e-12; void __print(int32_t x) { cout << x; } void __print(int x) { cout << x; } void __print(double x) { cout << x; } void __print(ld x) { cout << x; } void __print(float x) { cout << x; } void __print(bool x) { cout << (x ? "true" : "false"); } void __print(char x) { cout << '\'' << x << '\''; } void __print(const char *x) { cout << '\"' << x << '\"'; } void __print(const string &x) { cout << '\"' << x << '\"'; } template <typename T, typename V> void __print(const pair<T, V> &x) { cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}'; } template <typename T> void __print(const T &x) { int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}"; } void _print() { cout << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cout << ", "; _print(v...); } #ifndef ONLINE_JUDGE #define dbg(x...) \ cout << "[" << #x << "]=["; \ _print(x) #else #define dbg(x...) #endif int power(int base, int exp) { int res = 1; base %= mod; while (exp > 0) { if (exp & 1) res = (res * base) % mod; base = (base * base) % mod; exp = exp >> 1; } return res; } int inv(int x) { return power(x, mod - 2) % mod; } // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ const int N = 1e6 + 6, M = N; int i, j; void solve() { int k; cin >> k; if (k % 2 == 0) { cout << -1; return; } int cnt = 1, x = 7; while (x % k != 0) { x = (x * 10 + 7) % k; cnt++; } cout << cnt; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin>>t; for (int i = 1; i <= t; i++) { // cout<<"case #"<<i<<": "; solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define fi first #define se second #define pb push_back #define mp make_pair #define fo(i, n) for (i = 0; i < n; i++) #define fo1(i, n) for (i = 1; i <= n; i++) #define foab(i, a, b) for (i = a; i <= b; i++) #define of(i, n) for (i = n - 1; i >= 0; i--) #define of1(i, n) for (i = n; i >= 1; i--) #define ofab(i, a, b) for (i = a; i >= b; i--) #define sq(a) (a) * (a) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sortall(x) sort(all(x)) #define sortrall(x) sort(rall(x)) #define clr(x) memset(x, 0, sizeof(x)) #define tr(it, a) for (auto it = a.begin(); it != a.end(); it++) #define pii pair<int, int> #define mk(arr, n, type) type *arr = new type[n]; #define vi vector<int> #define si set<int> #define usi unordered_set<int> #define mii map<int, int> #define umii unordered_map<int, int> #define pqmx priority_queue<int> #define pqmn priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcountll(x) #define trailzrobits(x) __builtin_ctzll(x) #define leadzrobits(x) __builtin_clzll(x) #define paritybits(x) __builtin_parityll(x) #define gcd __gcd #define lcm(x, y) (x * y) / gcd(x, y) #define endl '\n' #define sz(s) (int)s.size() #define sp(x, y) fixed << setprecision(y) << x const int mod = 1000000007; const int inf = 1000000000000000000; const ld PI = 3.1415926535897932384626; const ld eps = 1e-12; void __print(int32_t x) { cout << x; } void __print(int x) { cout << x; } void __print(double x) { cout << x; } void __print(ld x) { cout << x; } void __print(float x) { cout << x; } void __print(bool x) { cout << (x ? "true" : "false"); } void __print(char x) { cout << '\'' << x << '\''; } void __print(const char *x) { cout << '\"' << x << '\"'; } void __print(const string &x) { cout << '\"' << x << '\"'; } template <typename T, typename V> void __print(const pair<T, V> &x) { cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}'; } template <typename T> void __print(const T &x) { int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}"; } void _print() { cout << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cout << ", "; _print(v...); } #ifndef ONLINE_JUDGE #define dbg(x...) \ cout << "[" << #x << "]=["; \ _print(x) #else #define dbg(x...) #endif int power(int base, int exp) { int res = 1; base %= mod; while (exp > 0) { if (exp & 1) res = (res * base) % mod; base = (base * base) % mod; exp = exp >> 1; } return res; } int inv(int x) { return power(x, mod - 2) % mod; } // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ const int N = 1e6 + 6, M = N; int i, j; void solve() { int k; cin >> k; if (k % 2 == 0) { cout << -1; return; } int cnt = 1, x = 7; while (x % k != 0) { x = (x * 10 + 7) % k; cnt++; if (cnt > (int)1e6) { cout << -1; return; } } cout << cnt; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin>>t; for (int i = 1; i <= t; i++) { // cout<<"case #"<<i<<": "; solve(); } return 0; }
insert
112
112
112
116
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long #define ls id << 1 #define rs id << 1 | 1 #define mem(array, value, size, type) \ memset(array, value, ((size) + 5) * sizeof(type)) #define memarray(array, value) memset(array, value, sizeof(array)) #define pb(x) push_back(x) #define st(x) (1LL << (x)) #define pii pair<int, int> #define mp(a, b) make_pair((a), (b)) #define Flush fflush(stdout) #define vecfirst (*vec.begin()) #define veclast (*vec.rbegin()) #define vecall(v) (v).begin(), (v).end() #define vecupsort(v) (sort((v).begin(), (v).end())) #define vecdownsort(v, type) (sort(vecall(v), greater<type>())) #define veccmpsort(v, cmp) (sort(vecall(v), cmp)) using namespace std; const int N = 500050; const int inf = 0x3f3f3f3f; const ll llinf = 0x3f3f3f3f3f3f3f3f; const ll mod = 998244353LL; const double PI = acos(-1.0); clock_t TIME__START, TIME__END; void program_end() { #ifdef ONLINE printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000); system("pause"); #endif } ll k; ll ans; ll now; void solve() { cin >> k; if (k % 2 == 0) return puts("-1"), void(); ans = 1, now = 7; while (1) { if (now % k == 0) break; ans++; now = (now * 10) + 7; now %= k; } printf("%lld\n", ans); } int main() { TIME__START = clock(); int Test = 1; // scanf("%d", &Test); while (Test--) solve(); TIME__END = clock(); program_end(); return 0; }
#include <bits/stdc++.h> #define ll long long #define ls id << 1 #define rs id << 1 | 1 #define mem(array, value, size, type) \ memset(array, value, ((size) + 5) * sizeof(type)) #define memarray(array, value) memset(array, value, sizeof(array)) #define pb(x) push_back(x) #define st(x) (1LL << (x)) #define pii pair<int, int> #define mp(a, b) make_pair((a), (b)) #define Flush fflush(stdout) #define vecfirst (*vec.begin()) #define veclast (*vec.rbegin()) #define vecall(v) (v).begin(), (v).end() #define vecupsort(v) (sort((v).begin(), (v).end())) #define vecdownsort(v, type) (sort(vecall(v), greater<type>())) #define veccmpsort(v, cmp) (sort(vecall(v), cmp)) using namespace std; const int N = 500050; const int inf = 0x3f3f3f3f; const ll llinf = 0x3f3f3f3f3f3f3f3f; const ll mod = 998244353LL; const double PI = acos(-1.0); clock_t TIME__START, TIME__END; void program_end() { #ifdef ONLINE printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000); system("pause"); #endif } ll k; ll ans; ll now; void solve() { cin >> k; if (k % 2 == 0 || k % 5 == 0) return puts("-1"), void(); ans = 1, now = 7; while (1) { if (now % k == 0) break; ans++; now = (now * 10) + 7; now %= k; } printf("%lld\n", ans); } int main() { TIME__START = clock(); int Test = 1; // scanf("%d", &Test); while (Test--) solve(); TIME__END = clock(); program_end(); return 0; }
replace
37
38
37
38
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <math.h> using namespace std; template <typename T> long long modpow(const T n, const T p, const T mod); template <typename T> long long modinv(const T n, const T mod); template <typename T> bool chmax(T &a, const T &b); template <typename T> bool chmin(T &a, const T &b); long long inf = 1000000007; int main() { long long k; cin >> k; long long ans = 0; long long hoge = 0; if (k % 2 == 0) { cout << -1 << endl; return 0; } while (true) { ans++; hoge *= 10; hoge += 7; if (hoge % k == 0) { cout << ans << endl; return 0; } hoge %= k; } return 0; } template <typename T> long long modpow(const T n, const T p, const T mod) { if (p == 0) return 1; if (p % 2 == 0) { long long a = modpow(n, p / 2, mod); return a * a % mod; } if (p % 2 == 1) return (modpow(n, p - 1, mod) * n) % mod; cerr << "ERROR" << endl; return 1; } template <typename T> long long modinv(const T n, const T mod) { return modpow(n, mod - 2, mod); } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
#include <bits/stdc++.h> #include <math.h> using namespace std; template <typename T> long long modpow(const T n, const T p, const T mod); template <typename T> long long modinv(const T n, const T mod); template <typename T> bool chmax(T &a, const T &b); template <typename T> bool chmin(T &a, const T &b); long long inf = 1000000007; int main() { long long k; cin >> k; long long ans = 0; long long hoge = 0; if (k % 2 == 0) { cout << -1 << endl; return 0; } while (true) { ans++; hoge *= 10; hoge += 7; if (hoge % k == 0) { cout << ans << endl; return 0; } hoge %= k; if (ans >= 1000000) { cout << -1 << endl; return 0; } } return 0; } template <typename T> long long modpow(const T n, const T p, const T mod) { if (p == 0) return 1; if (p % 2 == 0) { long long a = modpow(n, p / 2, mod); return a * a % mod; } if (p % 2 == 1) return (modpow(n, p - 1, mod) * n) % mod; cerr << "ERROR" << endl; return 1; } template <typename T> long long modinv(const T n, const T mod) { return modpow(n, mod - 2, mod); } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
insert
31
31
31
36
TLE
p02596
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using vec = vector<T>; template <class T> using vvec = vector<vec<T>>; int main() { cin.tie(0); ios::sync_with_stdio(false); int K; cin >> K; if (K % 2 == 0) { cout << -1 << "\n"; return 0; } int now = 0; for (int i = 1; i <= 1e8; i++) { now = (10 * now + 7) % K; if (now == 0) { cout << i << "\n"; return 0; } } assert(false); }
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using vec = vector<T>; template <class T> using vvec = vector<vec<T>>; int main() { cin.tie(0); ios::sync_with_stdio(false); int K; cin >> K; if (K % 2 == 0) { cout << -1 << "\n"; return 0; } int now = 0; for (int i = 1; i <= 1e8; i++) { now = (10 * now + 7) % K; if (now == 0) { cout << i << "\n"; return 0; } } cout << -1 << "\n"; }
replace
23
24
23
24
0
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } typedef long long ll; const long long INF = 1LL << 60; typedef pair<int, int> P; int main() { int K; cin >> K; int ans = 0; ll ct = 7; ll md = 0; if (K % 2 == 0) { cout << -1 << endl; return 0; } while (1) { md += ct % K; ct *= 10; ct %= K; ans++; if (md % K == 0) break; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } typedef long long ll; const long long INF = 1LL << 60; typedef pair<int, int> P; int main() { int K; cin >> K; int ans = 0; ll ct = 7; ll md = 0; if (K % 2 == 0) { cout << -1 << endl; return 0; } while (1) { md += ct % K; ct *= 10; ct %= K; ans++; if (md % K == 0) break; if (ans >= 1e7) { ans = -1; break; } } cout << ans << endl; return 0; }
insert
40
40
40
44
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define vl vector<ll> #define vi vector<int> #define vvl vector<vl> #define vvi vector<vi> #define pb push_back #define P pair<ll, ll> #define mp make_pair #define F first #define S second #define rep(i, n) for (ll i = 0; i < n; i++) #define Sort(v) sort(v.begin(), v.end()) #define all(v) v.begin(), v.end() ll mo = 1000000007; ll MO = 998244353; ll modpower(ll a, ll b, ll mod) { ll ans = 1; if (b == 0) { return 1; } if (b % 2 == 1) { ans = a; } ll x = modpower(a, b / 2, mod) % mod; ans *= (x * x) % mod; ans %= mod; return ans; } void pri(vl a) { for (auto i : a) cout << i << " "; cout << endl; } //------------------------------------------------------------------------------- void solve() { ll n; cin >> n; if (n % 2 == 0) { cout << -1 << endl; return; } ll ans = 1, val = 7; int x; while (val % n != 0) { // cout<<val<<endl; val %= n; val = (val * 10 + 7); ans++; } cout << ans << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); int nt = 1; // cin>>nt; while (nt--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define vl vector<ll> #define vi vector<int> #define vvl vector<vl> #define vvi vector<vi> #define pb push_back #define P pair<ll, ll> #define mp make_pair #define F first #define S second #define rep(i, n) for (ll i = 0; i < n; i++) #define Sort(v) sort(v.begin(), v.end()) #define all(v) v.begin(), v.end() ll mo = 1000000007; ll MO = 998244353; ll modpower(ll a, ll b, ll mod) { ll ans = 1; if (b == 0) { return 1; } if (b % 2 == 1) { ans = a; } ll x = modpower(a, b / 2, mod) % mod; ans *= (x * x) % mod; ans %= mod; return ans; } void pri(vl a) { for (auto i : a) cout << i << " "; cout << endl; } //------------------------------------------------------------------------------- void solve() { ll n; cin >> n; if (n % 2 == 0) { cout << -1 << endl; return; } ll ans = 1, val = 7; int x; while (val % n != 0) { // cout<<val<<endl; val %= n; val = (val * 10 + 7); ans++; if (ans > n) { cout << -1 << endl; return; } } cout << ans << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); int nt = 1; // cin>>nt; while (nt--) { solve(); } return 0; }
insert
57
57
57
61
TLE
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <vector> using namespace std; long long modAdd(long long a, long long b, long long mod) { return ((a % mod) + (b % mod)) % mod; } long long modSub(long long a, long long b, long long mod) { long long c = ((a % mod) - (b % mod)) % mod; return ((c < 0) ? c + mod : c); } long long modMul(long long a, long long b, long long mod) { return ((a % mod) * (b % mod)) % mod; } long long modPow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) { res = modMul(res, a, mod); } a = modMul(a, a, mod); n >>= 1; } return res; } long long modDiv(long long a, long long b, long long mod) { return modMul(a, modPow(b, mod - 2, mod), mod); } long long modCombination(long long n, long long r, long long mod) { if (r > n / 2) return modCombination(n, n - r, mod); long long res = 1; for (long long i = 1; i <= r; i++) { res = modMul(res, n - i + 1, mod); res = modDiv(res, i, mod); } return res; } int main() { long long k; cin >> k; vector<long long> m; int n = 0; m.push_back(7); if (k % 2 == 0) { cout << -1 << endl; } else { while (true) { if (m[n] % k == 0) break; m.push_back(modAdd(m[n], modMul(7, modPow(10, n + 1, k), k), k)); n++; } cout << n + 1 << endl; } return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <vector> using namespace std; long long modAdd(long long a, long long b, long long mod) { return ((a % mod) + (b % mod)) % mod; } long long modSub(long long a, long long b, long long mod) { long long c = ((a % mod) - (b % mod)) % mod; return ((c < 0) ? c + mod : c); } long long modMul(long long a, long long b, long long mod) { return ((a % mod) * (b % mod)) % mod; } long long modPow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) { res = modMul(res, a, mod); } a = modMul(a, a, mod); n >>= 1; } return res; } long long modDiv(long long a, long long b, long long mod) { return modMul(a, modPow(b, mod - 2, mod), mod); } long long modCombination(long long n, long long r, long long mod) { if (r > n / 2) return modCombination(n, n - r, mod); long long res = 1; for (long long i = 1; i <= r; i++) { res = modMul(res, n - i + 1, mod); res = modDiv(res, i, mod); } return res; } int main() { long long k; cin >> k; vector<long long> m; int n = 0; m.push_back(7); if (k % 2 == 0) { cout << -1 << endl; } else { while (true) { if (m[n] % k == 0) break; m.push_back(modAdd(m[n], modMul(7, modPow(10, n + 1, k), k), k)); n++; if (n >= 1000000) n = -2; } cout << n + 1 << endl; } return 0; }
insert
60
60
60
62
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define sws \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define ll long long #define vi vector<int> #define pb push_back #define pii pair<int, int> #define mp make_pair #define ff first #define ss second #define all(x) x.begin(), x.end() #define sz(x) ((int)x.size()) #define fo(i, n) for (int i = 0; i < n; i++) const int INF = 1e9; const ll INFLL = 0x3f3f3f3f3f3f3f3f; const int MOD = 1e9 + 7; ll eleva(ll x, int y, int mod) { ll res = 1; while (y) { if (y & 1) { res = (res * x) % mod; } y >>= 1; x = (x * x) % mod; } return res; } int main() { sws; ll k; cin >> k; if (!(k & 1)) { cout << "-1\n"; return 0; } int resto = 7 % k; int cont = 1; while (resto != 0) { resto = (resto + ((7 * eleva(10, cont, k)) % k)) % k; // cout << resto << endl; cont++; } cout << cont << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define sws \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define ll long long #define vi vector<int> #define pb push_back #define pii pair<int, int> #define mp make_pair #define ff first #define ss second #define all(x) x.begin(), x.end() #define sz(x) ((int)x.size()) #define fo(i, n) for (int i = 0; i < n; i++) const int INF = 1e9; const ll INFLL = 0x3f3f3f3f3f3f3f3f; const int MOD = 1e9 + 7; ll eleva(ll x, int y, int mod) { ll res = 1; while (y) { if (y & 1) { res = (res * x) % mod; } y >>= 1; x = (x * x) % mod; } return res; } int main() { sws; ll k; cin >> k; if (!(k & 1) or (k % 5 == 0)) { cout << "-1\n"; return 0; } int resto = 7 % k; int cont = 1; while (resto != 0) { resto = (resto + ((7 * eleva(10, cont, k)) % k)) % k; // cout << resto << endl; cont++; } cout << cont << endl; return 0; }
replace
43
44
43
44
TLE
p02596
C++
Time Limit Exceeded
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #include <bits/stdc++.h> using namespace std; int main() { long long int K, amari = 0, ba; std::cin >> K; if (K % 2 == 0) { cout << -1; } else { long long int i = 0; while (1) { i++; ba = amari; amari = (amari * 10 + 7) % K; if (amari == 0) { cout << i << endl; break; } if (amari == ba) { cout << -1 << endl; break; } } } return 0; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #include <bits/stdc++.h> using namespace std; int main() { long long int K, amari = 0, ba; std::cin >> K; if (K % 2 == 0) { cout << -1; } else { long long int i = 0; while (1) { i++; ba = amari; amari = (amari * 10 + 7) % K; if (amari == 0) { cout << i << endl; break; } if (amari == ba) { cout << -1 << endl; break; } if (i > K + 10) { cout << -1 << endl; break; } } } return 0; }
insert
27
27
27
31
TLE
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define rep(i, n) for (lint i = 0; i < n; i++) #define repr(i, n) for (lint i = n - 1; i >= 0; i--) #define repi(i, ini, n) for (lint i = ini; i < n; i++) #define repir(i, ini, n) for (lint i = n - 1; i >= ini; i--) #define repb(i, start, end) for (lint i = start; i <= end; i++) #define repbr(i, start, end) for (lint i = end; i >= start; i--) #define bit(n) (1LL << (n)) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rg(v, ini, end) v.begin() + ini, v.begin() + end #define ret return 0; #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) using lint = long long; using ulint = unsigned long long; using ld = long double; struct xy { lint x, y; xy() : x(0), y(0) {} xy(lint _x, lint _y) : x(_x), y(_y) {} xy operator+(const xy &p) const { return xy(x + p.x, y + p.y); } bool operator<(xy p) const { if (y == p.y) return x < p.x; return y < p.y; } }; struct xyd { ld x, y; xyd() : x(0), y(0) {} xyd(long double _x, long double _y) : x(_x), y(_y) {} }; using vec = vector<lint>; using vecd = vector<ld>; using vecs = vector<string>; using vecp = vector<xy>; template <class T> using vect = vector<T>; class vec2 : public vector<vector<lint>> { public: vec2() {} vec2(lint n) : vector(n) {} vec2(lint h, lint w) : vector(h, vector<lint>(w)) {} vec2(lint h, lint w, lint v) : vector(h, vector<lint>(w, v)) {} }; template <class T> using priq = priority_queue<T>; template <class T> using rpriq = priority_queue<T, vector<T>, greater<T>>; template <class Key, class Val> using hashmap = unordered_map<Key, Val>; template <class Key> using hashset = unordered_set<Key>; template <class It> constexpr typename It::value_type rmax(It begin, It end) { return *max_element(begin, end); } template <class T1, class T2> constexpr auto mmax(T1 arg1, T2 arg2) { using T = decltype(arg1 + arg2); return max(T(arg1), T(arg2)); } template <class T, class... Types> constexpr auto mmax(T arg0, Types... args) { return mmax(arg0, mmax(args...)); } template <class It> constexpr typename It::value_type rmin(It begin, It end) { return *min_element(begin, end); } template <class T1, class T2> constexpr auto mmin(T1 arg1, T2 arg2) { using T = decltype(arg1 + arg2); return min(T(arg1), T(arg2)); } template <class T, class... Types> constexpr auto mmin(T arg0, Types... args) { return mmin(arg0, mmin(args...)); } mt19937 mtrand((random_device())()); const double pi = 3.141592653589793238462; const lint intmax = 9223372036854775807; const lint inf = 1100100100100100100LL; constexpr lint div2(lint p, lint q) { return (p + q - 1) / q; } #if (__cplusplus < 201703L) lint gcd(lint a, lint b) { while (1) { if (a < b) swap(a, b); if (!b) break; a %= b; } return a; } lint lcm(lint a, lint b) { return a / gcd(a, b) * b; } #endif template <class T> struct nval { lint n; // counts T val; nval() : n(0){}; nval(lint _n, T _val) : n(_n), val(_val){}; }; template <class It, class It2> auto spacel(It i, It2 end) { if (i + 1 == end) { return '\n'; } else { return ' '; } } ostream &setp(ostream &ost) { cout << setprecision(60) << fixed; return ost; } const ulint mod = 1000000007; // const ulint mod = 998244353; const ld eps = 0.0000001; int main() { lint k; cin >> k; if (k % 2 == 0) { cout << -1 << endl; ret; } lint n = 7, d = 7, i = 1; while (1) { if (n % k == 0) { cout << i << endl; break; } d *= 10; n += d; d %= k; n %= k; i++; } return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define rep(i, n) for (lint i = 0; i < n; i++) #define repr(i, n) for (lint i = n - 1; i >= 0; i--) #define repi(i, ini, n) for (lint i = ini; i < n; i++) #define repir(i, ini, n) for (lint i = n - 1; i >= ini; i--) #define repb(i, start, end) for (lint i = start; i <= end; i++) #define repbr(i, start, end) for (lint i = end; i >= start; i--) #define bit(n) (1LL << (n)) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rg(v, ini, end) v.begin() + ini, v.begin() + end #define ret return 0; #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) using lint = long long; using ulint = unsigned long long; using ld = long double; struct xy { lint x, y; xy() : x(0), y(0) {} xy(lint _x, lint _y) : x(_x), y(_y) {} xy operator+(const xy &p) const { return xy(x + p.x, y + p.y); } bool operator<(xy p) const { if (y == p.y) return x < p.x; return y < p.y; } }; struct xyd { ld x, y; xyd() : x(0), y(0) {} xyd(long double _x, long double _y) : x(_x), y(_y) {} }; using vec = vector<lint>; using vecd = vector<ld>; using vecs = vector<string>; using vecp = vector<xy>; template <class T> using vect = vector<T>; class vec2 : public vector<vector<lint>> { public: vec2() {} vec2(lint n) : vector(n) {} vec2(lint h, lint w) : vector(h, vector<lint>(w)) {} vec2(lint h, lint w, lint v) : vector(h, vector<lint>(w, v)) {} }; template <class T> using priq = priority_queue<T>; template <class T> using rpriq = priority_queue<T, vector<T>, greater<T>>; template <class Key, class Val> using hashmap = unordered_map<Key, Val>; template <class Key> using hashset = unordered_set<Key>; template <class It> constexpr typename It::value_type rmax(It begin, It end) { return *max_element(begin, end); } template <class T1, class T2> constexpr auto mmax(T1 arg1, T2 arg2) { using T = decltype(arg1 + arg2); return max(T(arg1), T(arg2)); } template <class T, class... Types> constexpr auto mmax(T arg0, Types... args) { return mmax(arg0, mmax(args...)); } template <class It> constexpr typename It::value_type rmin(It begin, It end) { return *min_element(begin, end); } template <class T1, class T2> constexpr auto mmin(T1 arg1, T2 arg2) { using T = decltype(arg1 + arg2); return min(T(arg1), T(arg2)); } template <class T, class... Types> constexpr auto mmin(T arg0, Types... args) { return mmin(arg0, mmin(args...)); } mt19937 mtrand((random_device())()); const double pi = 3.141592653589793238462; const lint intmax = 9223372036854775807; const lint inf = 1100100100100100100LL; constexpr lint div2(lint p, lint q) { return (p + q - 1) / q; } #if (__cplusplus < 201703L) lint gcd(lint a, lint b) { while (1) { if (a < b) swap(a, b); if (!b) break; a %= b; } return a; } lint lcm(lint a, lint b) { return a / gcd(a, b) * b; } #endif template <class T> struct nval { lint n; // counts T val; nval() : n(0){}; nval(lint _n, T _val) : n(_n), val(_val){}; }; template <class It, class It2> auto spacel(It i, It2 end) { if (i + 1 == end) { return '\n'; } else { return ' '; } } ostream &setp(ostream &ost) { cout << setprecision(60) << fixed; return ost; } const ulint mod = 1000000007; // const ulint mod = 998244353; const ld eps = 0.0000001; int main() { lint k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; ret; } lint n = 7, d = 7, i = 1; while (1) { if (n % k == 0) { cout << i << endl; break; } d *= 10; n += d; d %= k; n %= k; i++; } return 0; }
replace
157
158
157
158
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define MOD 1e9 + 7; using namespace std; using ll = long long; int main() { ll k, ans = 1; cin >> k; int seven = 7; if (k % 2 == 0) { cout << "-1"; return 0; } while (seven % k != 0) { seven = (seven * 10 + 7) % k; ans++; } cout << ans; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define MOD 1e9 + 7; using namespace std; using ll = long long; int main() { ll k, ans = 1; cin >> k; int seven = 7; if (k % 2 == 0) { cout << "-1"; return 0; } while (seven % k != 0) { seven = (seven * 10 + 7) % k; ans++; if (ans > 1000000) { cout << "-1"; return 0; } } cout << ans; return 0; }
insert
17
17
17
21
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) typedef long long ll; int main() { ll k; cin >> k; if (k % 2 == 0) { cout << -1 << endl; return 0; } ll seven = 7; ll count = 1; while (true) { if (seven % k == 0) { cout << count << endl; return 0; } seven *= 10; seven += 7; seven %= k; count++; } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) typedef long long ll; int main() { ll k; cin >> k; if (k % 2 == 0) { cout << -1 << endl; return 0; } ll seven = 7; ll count = 1; while (true) { if (seven % k == 0) { cout << count << endl; return 0; } seven *= 10; seven += 7; seven %= k; count++; if (count > k) { cout << -1 << endl; return 0; } } return 0; }
insert
24
24
24
28
TLE
p02596
C++
Runtime Error
#include <bits/stdc++.h> #define sz 100002 #define pb push_back #define ff first #define ss second #define ll long long #define P push #define PQ priority_queue<double, vector<double>, greater<double>> q #define VEC(n) \ ll int x; \ vector<ll int> v; \ for (int i = 0; i < n; i++) { \ cin >> x; \ v.pb(x); \ } #define TEST() \ int test; \ cin >> test; \ while (test--) #define FAST() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) using namespace std; // Upper_bound auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; // if(x==v[a].end())break; ll int LCM(ll int a,ll int b) { ll int // gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;} ll int bigmod(ll int b, ll int // p, ll int m){if(p==0)return 1;if(p%2!=0) return // b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return // (res%m*res%m)%m;}} void seive() { prime[np++]=2;for(i=3; i<=sz; // i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }} // string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int // i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else // m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else { c=0;s+=m+'0'; }j--; } // if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;} int pos;string // mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; // for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { // s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { // s+=c%10+'0';c=c/10;} reverse(s.begin(),s.end());return s;} int main() { FAST(); int n, res = -1, num = 0; cin >> n; for (int i = 1; i <= n + 1; i++) { num = num * 10 + 7; num %= n; if (num == 0) { cout << i << endl; return 0; } } return -1; }
#include <bits/stdc++.h> #define sz 100002 #define pb push_back #define ff first #define ss second #define ll long long #define P push #define PQ priority_queue<double, vector<double>, greater<double>> q #define VEC(n) \ ll int x; \ vector<ll int> v; \ for (int i = 0; i < n; i++) { \ cin >> x; \ v.pb(x); \ } #define TEST() \ int test; \ cin >> test; \ while (test--) #define FAST() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) using namespace std; // Upper_bound auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; // if(x==v[a].end())break; ll int LCM(ll int a,ll int b) { ll int // gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;} ll int bigmod(ll int b, ll int // p, ll int m){if(p==0)return 1;if(p%2!=0) return // b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return // (res%m*res%m)%m;}} void seive() { prime[np++]=2;for(i=3; i<=sz; // i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }} // string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int // i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else // m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else { c=0;s+=m+'0'; }j--; } // if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;} int pos;string // mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; // for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { // s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { // s+=c%10+'0';c=c/10;} reverse(s.begin(),s.end());return s;} int main() { FAST(); int n, res = -1, num = 0; cin >> n; for (int i = 1; i <= n + 1; i++) { num = num * 10 + 7; num %= n; if (num == 0) { cout << i << endl; return 0; } } cout << "-1" << endl; }
replace
53
54
53
54
0
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <climits> // FOO_MAX, FOO_MIN #include <cmath> #include <cstdlib> // abs(int) #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> using namespace std; #define roundup(n, d) (((n) + ((d)-1)) / (d)) #define assign_max(into, compared) (into = max((into), (compared))) #define assign_min(into, compared) (into = min((into), (compared))) #define rep(i, n) for (long long i = 0; i < n; ++i) #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(nullptr); #define fix(n) fixed << setprecision(n) #define ALL(v) v.begin(), v.end() #define PI 3.14159265358979323846; using ll = long long; using ull = unsigned long long; using vll = vector<long long>; int main(void) { FAST_IO ll k; cin >> k; ll count = 1; ll n = 7; if (k % 2 == 0 && k % 5 == 0) { cout << -1 << endl; return 0; } while (n % k > 0) { n = (n * 10 + 7) % k; count++; } cout << count << endl; return 0; }
#include <algorithm> #include <climits> // FOO_MAX, FOO_MIN #include <cmath> #include <cstdlib> // abs(int) #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> using namespace std; #define roundup(n, d) (((n) + ((d)-1)) / (d)) #define assign_max(into, compared) (into = max((into), (compared))) #define assign_min(into, compared) (into = min((into), (compared))) #define rep(i, n) for (long long i = 0; i < n; ++i) #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(nullptr); #define fix(n) fixed << setprecision(n) #define ALL(v) v.begin(), v.end() #define PI 3.14159265358979323846; using ll = long long; using ull = unsigned long long; using vll = vector<long long>; int main(void) { FAST_IO ll k; cin >> k; ll count = 1; ll n = 7; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; return 0; } while (n % k > 0) { n = (n * 10 + 7) % k; count++; } cout << count << endl; return 0; }
replace
36
37
36
37
TLE
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <assert.h> #include <bitset> #include <deque> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; #define FOR(i, n) for (int i = 0; i < n; i++) #define FORa(i, a, b) for (int i = a; i < b; i++) #define pb(x) push_back(x) #define mp(a, b) make_pair(a, b) #define F first #define S second #define SORT(a, n) sort(begin(a), begin(a) + n) #define VSORT(v) sort(v.begin(), v.end()) #define MAX 1000000 #define ll long long #define LOW(s) transform(s.begin(), s.end(), s.begin(), ::tolower) #define UP(s) transform(s.begin(), s.end(), s.begin(), ::toupper) //-------------------------------------------------------// int main() { int k; cin >> k; if (k == 2 || k == 5) cout << "-1" << endl; else { int a = 1, b = 7 % k; while (b != 0) { b = (b * 10 + 7) % k; a++; } cout << a << endl; } return 0; }
#include <algorithm> #include <assert.h> #include <bitset> #include <deque> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; #define FOR(i, n) for (int i = 0; i < n; i++) #define FORa(i, a, b) for (int i = a; i < b; i++) #define pb(x) push_back(x) #define mp(a, b) make_pair(a, b) #define F first #define S second #define SORT(a, n) sort(begin(a), begin(a) + n) #define VSORT(v) sort(v.begin(), v.end()) #define MAX 1000000 #define ll long long #define LOW(s) transform(s.begin(), s.end(), s.begin(), ::tolower) #define UP(s) transform(s.begin(), s.end(), s.begin(), ::toupper) //-------------------------------------------------------// int main() { int k; cin >> k; if (k % 2 == 0 || k % 5 == 0) cout << "-1" << endl; else { int a = 1, b = 7 % k; while (b != 0) { b = (b * 10 + 7) % k; a++; } cout << a << endl; } return 0; }
replace
47
48
47
48
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; // const int N = ; int k; int main() { cin >> k; if (k % 2 == 0) puts("-1"); else { int x = 7, ans = 1; x %= k; while (x != 0) { x = (x * 10 + 7) % k; ans++; } cout << ans; } return 0; }
#include <bits/stdc++.h> using namespace std; // const int N = ; int k; int main() { cin >> k; if (k % 2 == 0 || k % 5 == 0) puts("-1"); else { int x = 7, ans = 1; x %= k; while (x != 0) { x = (x * 10 + 7) % k; ans++; } cout << ans; } return 0; }
replace
6
7
6
7
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { unsigned int K; cin >> K; if (K % 2 == 0 || K % 5 == 0) { cout << -1 << endl; return 0; } unsigned int i = 0; unsigned int ai = 0; while (true) { i++; ai = ai * 10 + 7; if (ai % K == 0) { cout << i << endl; return 0; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { unsigned int K; cin >> K; if (K % 2 == 0 || K % 5 == 0) { cout << -1 << endl; return 0; } unsigned int i = 0; unsigned int ai = 0; while (true) { i++; ai = (ai * 10 + 7) % K; if (ai == 0) { cout << i << endl; return 0; } } return 0; }
replace
16
18
16
18
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll k; cin >> k; ll tmpk = k, rank = 0; while (tmpk) { tmpk /= 10; rank++; } ll ans = 1; if (k % 2 == 0 && k / 2 > 0) { ans = -1; } else { ll sevens = 7; for (int i = 1; i < rank; i++) { sevens *= 10; sevens += 7; ans++; } ll amari = sevens % k; while (amari) { amari %= k; if (amari == 0) break; ans++; amari *= 10; amari += 7; if (ans >= 1000000000) { ans = -1; break; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll k; cin >> k; ll tmpk = k, rank = 0; while (tmpk) { tmpk /= 10; rank++; } ll ans = 1; if (k % 2 == 0 && k / 2 > 0) { ans = -1; } else { ll sevens = 7; for (int i = 1; i < rank; i++) { sevens *= 10; sevens += 7; ans++; } ll amari = sevens % k; while (amari) { amari %= k; if (amari == 0) break; ans++; amari *= 10; amari += 7; if (ans >= 100000000) { ans = -1; break; } } } cout << ans << endl; }
replace
33
34
33
34
TLE
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <vector> // #include <stdio.h> // #include <stack> // #include <queue> // #include <cstdio> #include <cmath> #include <fstream> #include <iterator> #include <map> // #include <list> #include <iomanip> // #include <stdlib.h> // #include <cctype> using namespace std; #define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define prec std::cout << std::fixed << std::setprecision(15); #define endl "\n" #define MOD 1000000007 #define Int int64_t #define PI 3.14159265358979 // #define rep(i, n) for (int i = 0; i < int(n); i++) #define ssort(z) sort(z.begin(), z.end()) #define rsort(z) sort(z.rbegin(), z.rend()) #define eerase(z) z.erase(unique(z.begin(), z.end()), z.end()) #define ccnt(z, w) count(z.begin(), z.end(), w) #define rep(i, a, n) for (Int(i) = (a); (i) < (n); (i)++) #define repq(i, a, n) for (Int(i) = (a); (i) <= (n); (i)++) const int MAX_N = 1000000; const Int MAX_N_Int = 1000000000000; template <typename T> void printV(const std::vector<T> &v, const char *const separator = " ") { if (!v.empty()) { std::copy(v.begin(), --v.end(), std::ostream_iterator<T>(std::cout, separator)); std::cout << v.back() << "\n"; } } bool isPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } Int gcd(Int a, Int b) { return b != 0 ? gcd(b, a % b) : a; } Int lcm(Int a, Int b) { return a / gcd(a, b) * b; // a*bは64bit integer overflow } int Max(int a, int b, int c) { int temp = max(a, b); return max(temp, c); } int Min(int a, int b, int c) { int temp = min(a, b); return min(temp, c); } bool integer(double num) { return floor(num) == num; } Int fact(int num) { if (num == 0) return 1; else return num * fact(num - 1); } Int yakusu(int n) { int cnt = 0; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { cnt++; if (i * i != n) cnt++; } } return cnt; } Int fact_mod(Int n, Int mod) { Int f = 1; repq(i, 2, n) f = f * (i % MOD) % MOD; return f; } // 繰り返し二乗法 (modの世界での累乗) Int mod_pow(Int x, Int n, Int mod) { Int res = 1; while (n > 0) { if (n & 1) res = (res * x) % mod; x = (x * x) % mod; n >>= 1; } return res; } // 組み合わせ nCr を求める Int combination_mod(Int n, Int r, Int mod) { if (r > n - r) r = n - r; if (r == 0) return 1; Int a = 1; rep(i, 0, r) a = a * ((n - i) % mod) % mod; Int b = mod_pow(fact_mod(r, mod), mod - 2, mod); return (a % mod) * (b % mod) % mod; } bool rev(string s) { string t = s; reverse(s.begin(), s.end()); return s == t; } int main() { IOS; prec; Int a, b, c, q, n, m, x, k, d, y = 0, ans = 0, ans2 = 0; string str, s, t, u; cin >> k; Int now = 7; if (k % 2 == 0) { cout << -1; return 0; } else { Int cnt = 1; while (now % k != 0) { cnt++; now = now * 10 + 7; now %= k; } cout << cnt; } cout << endl; return 0; } /* テレビも無ェ ラジオも無ェ 自動車もそれほど走って無ェ ピアノも無ェ バーも無ェ 巡査 毎日ぐーるぐる 朝起ぎで 牛連れで 二時間ちょっとの散歩道 電話も無ェ 瓦斯も無ェ バスは一日一度来る 俺らこんな村いやだ 俺らこんな村いやだ 東京へ出るだ 東京へ出だなら 銭コァ貯めで 東京でベコ(牛)飼うだ */
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <vector> // #include <stdio.h> // #include <stack> // #include <queue> // #include <cstdio> #include <cmath> #include <fstream> #include <iterator> #include <map> // #include <list> #include <iomanip> // #include <stdlib.h> // #include <cctype> using namespace std; #define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define prec std::cout << std::fixed << std::setprecision(15); #define endl "\n" #define MOD 1000000007 #define Int int64_t #define PI 3.14159265358979 // #define rep(i, n) for (int i = 0; i < int(n); i++) #define ssort(z) sort(z.begin(), z.end()) #define rsort(z) sort(z.rbegin(), z.rend()) #define eerase(z) z.erase(unique(z.begin(), z.end()), z.end()) #define ccnt(z, w) count(z.begin(), z.end(), w) #define rep(i, a, n) for (Int(i) = (a); (i) < (n); (i)++) #define repq(i, a, n) for (Int(i) = (a); (i) <= (n); (i)++) const int MAX_N = 1000000; const Int MAX_N_Int = 1000000000000; template <typename T> void printV(const std::vector<T> &v, const char *const separator = " ") { if (!v.empty()) { std::copy(v.begin(), --v.end(), std::ostream_iterator<T>(std::cout, separator)); std::cout << v.back() << "\n"; } } bool isPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } Int gcd(Int a, Int b) { return b != 0 ? gcd(b, a % b) : a; } Int lcm(Int a, Int b) { return a / gcd(a, b) * b; // a*bは64bit integer overflow } int Max(int a, int b, int c) { int temp = max(a, b); return max(temp, c); } int Min(int a, int b, int c) { int temp = min(a, b); return min(temp, c); } bool integer(double num) { return floor(num) == num; } Int fact(int num) { if (num == 0) return 1; else return num * fact(num - 1); } Int yakusu(int n) { int cnt = 0; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { cnt++; if (i * i != n) cnt++; } } return cnt; } Int fact_mod(Int n, Int mod) { Int f = 1; repq(i, 2, n) f = f * (i % MOD) % MOD; return f; } // 繰り返し二乗法 (modの世界での累乗) Int mod_pow(Int x, Int n, Int mod) { Int res = 1; while (n > 0) { if (n & 1) res = (res * x) % mod; x = (x * x) % mod; n >>= 1; } return res; } // 組み合わせ nCr を求める Int combination_mod(Int n, Int r, Int mod) { if (r > n - r) r = n - r; if (r == 0) return 1; Int a = 1; rep(i, 0, r) a = a * ((n - i) % mod) % mod; Int b = mod_pow(fact_mod(r, mod), mod - 2, mod); return (a % mod) * (b % mod) % mod; } bool rev(string s) { string t = s; reverse(s.begin(), s.end()); return s == t; } int main() { IOS; prec; Int a, b, c, q, n, m, x, k, d, y = 0, ans = 0, ans2 = 0; string str, s, t, u; cin >> k; Int now = 7; if (k % 2 == 0) { cout << -1; return 0; } else { Int cnt = 1; while (now % k != 0) { cnt++; now = now * 10 + 7; now %= k; if (cnt >= 1000000) { cout << -1; return 0; } } cout << cnt; } cout << endl; return 0; } /* テレビも無ェ ラジオも無ェ 自動車もそれほど走って無ェ ピアノも無ェ バーも無ェ 巡査 毎日ぐーるぐる 朝起ぎで 牛連れで 二時間ちょっとの散歩道 電話も無ェ 瓦斯も無ェ バスは一日一度来る 俺らこんな村いやだ 俺らこんな村いやだ 東京へ出るだ 東京へ出だなら 銭コァ貯めで 東京でベコ(牛)飼うだ */
insert
153
153
153
157
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < n; ++i) #define P pair<ll, ll> #define Graph vector<vector<P>> #define fi first #define se second constexpr ll mod = 1000000007; constexpr ll INF = (1ll << 60); constexpr double pi = 3.14159265358979323846; template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } int main() { ll k; cin >> k; if (k % 2 == 0) { cout << -1 << endl; return 0; } ll ans = 1, num = 7; while (num % k != 0) { num = (10 * num + 7) % k; ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < n; ++i) #define P pair<ll, ll> #define Graph vector<vector<P>> #define fi first #define se second constexpr ll mod = 1000000007; constexpr ll INF = (1ll << 60); constexpr double pi = 3.14159265358979323846; template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } int main() { ll k; cin >> k; if (k % 2 == 0) { cout << -1 << endl; return 0; } ll ans = 1, num = 7; while (num % k != 0) { num = (10 * num + 7) % k; ans++; if (ans > 2 * 1e6) { cout << -1 << endl; return 0; } } cout << ans << endl; return 0; }
insert
38
38
38
42
TLE
p02596
C++
Time Limit Exceeded
#pragma GCC optimize("O3") #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("unroll-loops") #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 int long long #define pb push_back #define pf push_front #define eb emplace_back #define mp make_pair #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define f first #define s second #define sz(x) (int)x.size() #define endl "\n" #define forn(i, n) for (int i = 0; i < n; ++i) #define fore(i, l, r) for (int i = int(l); i <= int(r); ++i) #define rep(i, begin, end) for (__typeof(end) i = (begin); i != (end); i++) #define fill(a, value) memset(a, value, sizeof(a)); #define gcd(a, b) __gcd((a), (b)) #define watch1(x) cout << (x) << endl #define watch2(x, y) cout << (x) << " " << (y) << endl #define watch3(x, y, z) cout << (x) << " " << (y) << " " << (z) << endl #define fastio \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vpii; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset; const int INF = 9e18; const int mod = 1e9 + 7; const int N = 2e5 + 5; int i, k; void solve() { cin >> k; if (k % 2 == 0) { cout << -1; return; } if (k % 7 == 0) k /= 7; int ans = 1 % k, cnt = 1; while (true) { if (!ans) break; ans = (ans * 10 + 1) % k; cnt++; } cout << cnt; } signed main() { fastio; int t; // cin>>t; t = 1; while (t--) { solve(); } return 0; }
#pragma GCC optimize("O3") #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("unroll-loops") #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 int long long #define pb push_back #define pf push_front #define eb emplace_back #define mp make_pair #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define f first #define s second #define sz(x) (int)x.size() #define endl "\n" #define forn(i, n) for (int i = 0; i < n; ++i) #define fore(i, l, r) for (int i = int(l); i <= int(r); ++i) #define rep(i, begin, end) for (__typeof(end) i = (begin); i != (end); i++) #define fill(a, value) memset(a, value, sizeof(a)); #define gcd(a, b) __gcd((a), (b)) #define watch1(x) cout << (x) << endl #define watch2(x, y) cout << (x) << " " << (y) << endl #define watch3(x, y, z) cout << (x) << " " << (y) << " " << (z) << endl #define fastio \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vpii; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset; const int INF = 9e18; const int mod = 1e9 + 7; const int N = 2e5 + 5; int i, k; void solve() { cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1; return; } if (k % 7 == 0) k /= 7; int ans = 1 % k, cnt = 1; while (true) { if (!ans) break; ans = (ans * 10 + 1) % k; cnt++; } cout << cnt; } signed main() { fastio; int t; // cin>>t; t = 1; while (t--) { solve(); } return 0; }
replace
53
54
53
54
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(a) (a).begin(), (a).end() #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(n) for (ll i = 0; i < (n); i++) #define rep2(i, n) for (ll i = 0; i < (n); i++) #define rep3(i, a, b) for (ll i = (a); i < (b); i++) #define rep4(i, a, b, c) for (ll i = (a); i < (b); i += (c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) for (ll i = (n)-1; i >= 0; i--) #define rrep2(i, n) for (ll i = (n)-1; i >= 0; i--) #define rrep3(i, a, b) for (ll i = (a)-1; i >= (b); i--) #define rrep4(i, a, b, c) for (ll i = (a)-1; i >= (b); i -= (c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) const ll INF = 1e18, MOD = 1e9 + 7; const int iINF = 1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int seven = 7, k, ans = 1; cin >> k; if (k % 2 == 0) { ans = -1; } else { while (true) { if (seven % k == 0) break; seven = seven % k; seven = seven * 10 + 7; ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(a) (a).begin(), (a).end() #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(n) for (ll i = 0; i < (n); i++) #define rep2(i, n) for (ll i = 0; i < (n); i++) #define rep3(i, a, b) for (ll i = (a); i < (b); i++) #define rep4(i, a, b, c) for (ll i = (a); i < (b); i += (c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) for (ll i = (n)-1; i >= 0; i--) #define rrep2(i, n) for (ll i = (n)-1; i >= 0; i--) #define rrep3(i, a, b) for (ll i = (a)-1; i >= (b); i--) #define rrep4(i, a, b, c) for (ll i = (a)-1; i >= (b); i -= (c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) const ll INF = 1e18, MOD = 1e9 + 7; const int iINF = 1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int seven = 7, k, ans = 1; cin >> k; if (k % 2 == 0) { ans = -1; } else { while (true) { if (seven % k == 0) break; if (ans > 1e7) { ans = -1; break; } seven = seven % k; seven = seven * 10 + 7; ans++; } } cout << ans << endl; return 0; }
insert
31
31
31
35
TLE
p02596
C++
Time Limit Exceeded
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= *$* WRITER:kakitamasziru/OxOmisosiru *$* ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/ #ifdef LOCAL_JUDGE #define _GLIBCXX_DEBUG #endif #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <cstdint> // int64_t, int*_t #include <iomanip> #include <iostream> // cout, endl, cin #include <limits> //setprecision #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <utility> // pair, make_pair #include <vector> // vector // #include <cstdio> // printf #include <map> // map #include <queue> // queue, priority_queue #include <set> // set // #include <unordered_set> //unordered_set #include <bitset> // bitset #include <cmath> //abs,,, #include <deque> // deque #include <math.h> //pow,,, #include <stack> // stack #define endl "\n"; using namespace std; const long long INF = 100100100100100; const int MOD = 1000000007; const int inf = 1001001001; typedef pair<int, int> P; // Solve N^M. This, mod_pow use Iterative Square Method. long long mod_pow(long long N, long long M) { if (M == 0) return 1; long long res = mod_pow((N * N) % MOD, M / 2); // 最下位ビット(*N)が1の時は単独でNをかける if (M & 1) res = (res * N) % MOD; return res %= MOD; } long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); long long K; cin >> K; if (K % 2 == 0) { cout << -1 << endl; return 0; } long long ans = 0; long long amari = 0; while (true) { ans++; amari = amari * 10 + 7; amari %= K; if (amari % K == 0) break; } cout << ans << endl; }
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= *$* WRITER:kakitamasziru/OxOmisosiru *$* ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/ #ifdef LOCAL_JUDGE #define _GLIBCXX_DEBUG #endif #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <cstdint> // int64_t, int*_t #include <iomanip> #include <iostream> // cout, endl, cin #include <limits> //setprecision #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <utility> // pair, make_pair #include <vector> // vector // #include <cstdio> // printf #include <map> // map #include <queue> // queue, priority_queue #include <set> // set // #include <unordered_set> //unordered_set #include <bitset> // bitset #include <cmath> //abs,,, #include <deque> // deque #include <math.h> //pow,,, #include <stack> // stack #define endl "\n"; using namespace std; const long long INF = 100100100100100; const int MOD = 1000000007; const int inf = 1001001001; typedef pair<int, int> P; // Solve N^M. This, mod_pow use Iterative Square Method. long long mod_pow(long long N, long long M) { if (M == 0) return 1; long long res = mod_pow((N * N) % MOD, M / 2); // 最下位ビット(*N)が1の時は単独でNをかける if (M & 1) res = (res * N) % MOD; return res %= MOD; } long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); long long K; cin >> K; if (K % 2 == 0 || K % 5 == 0) { cout << -1 << endl; return 0; } long long ans = 0; long long amari = 0; while (true) { ans++; amari = amari * 10 + 7; amari %= K; if (amari % K == 0) break; } cout << ans << endl; }
replace
59
60
59
60
TLE
p02596
C++
Time Limit Exceeded
// Patwari26 // #include template<t> as mine #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define endl '\n' #define mii map<ll, ll> #define pii pair<ll, ll> #define vi vector<ll> #define all(a) (a).begin(), (a).end() #define x first #define y second #define sz(x) (ll) x.size() #define hell 1000000007 #define INF (1ll << 60) #define rep(i, a, b) for (ll i = a; i <= b; i++) #define rrep(i, a, b) for (ll i = a; i >= b; i--) #define ios \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define time \ cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); } const int N = 100005; void solve() { ll n; cin >> n; if (n % 2 == 0) { cout << "-1" << endl; return; } ll ans = 1; ll temp = 7; while (temp % n != 0) { temp = (temp * 10 + 7) % n; ans++; } cout << ans << endl; } signed main() { ios int TESTS = 1; // cin>>TESTS; while (TESTS--) { solve(); } // time return 0; }
// Patwari26 // #include template<t> as mine #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define endl '\n' #define mii map<ll, ll> #define pii pair<ll, ll> #define vi vector<ll> #define all(a) (a).begin(), (a).end() #define x first #define y second #define sz(x) (ll) x.size() #define hell 1000000007 #define INF (1ll << 60) #define rep(i, a, b) for (ll i = a; i <= b; i++) #define rrep(i, a, b) for (ll i = a; i >= b; i--) #define ios \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define time \ cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); } const int N = 100005; void solve() { ll n; cin >> n; if (n % 2 == 0 || n % 5 == 0) { cout << "-1" << endl; return; } ll ans = 1; ll temp = 7; while (temp % n != 0) { temp = (temp * 10 + 7) % n; ans++; } cout << ans << endl; } signed main() { ios int TESTS = 1; // cin>>TESTS; while (TESTS--) { solve(); } // time return 0; }
replace
31
32
31
32
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; ////////////////// #ifdef DEBUG #include "debug.h" #define dump(...) \ DUMPOUT << " " << string(#__VA_ARGS__) << ": " \ << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \ << " ", \ dump_func(__VA_ARGS__) #else #define dump(...) #endif // http://beet-aizu.hatenablog.com/entry/2018/04/08/145516 template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; } template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } ////////////////// #define int long long #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define YES puts("YES") #define Yes puts("Yes") #define NO puts("NO") #define No puts("No") #define ALL(v) (v).begin(), (v).end() int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } 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 (a > b) { a = b; return 1; } return 0; } //* #define mod \ 1000000007 /*/ \ #define mod 998244353 //*/ typedef pair<int, int> P; #define INF (1LL << 60) void solve() { int K; cin >> K; if (K % 2 == 0) cout << -1 << endl; else { int t = 0; for (int i = 1;; i++) { t = t * 10 + 7; t %= K; if (t == 0) { cout << i << endl; return; } } } } signed main() { cout << fixed << setprecision(18); cerr << fixed << setprecision(18); solve(); }
#include <bits/stdc++.h> using namespace std; ////////////////// #ifdef DEBUG #include "debug.h" #define dump(...) \ DUMPOUT << " " << string(#__VA_ARGS__) << ": " \ << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \ << " ", \ dump_func(__VA_ARGS__) #else #define dump(...) #endif // http://beet-aizu.hatenablog.com/entry/2018/04/08/145516 template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; } template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } ////////////////// #define int long long #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define YES puts("YES") #define Yes puts("Yes") #define NO puts("NO") #define No puts("No") #define ALL(v) (v).begin(), (v).end() int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } 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 (a > b) { a = b; return 1; } return 0; } //* #define mod \ 1000000007 /*/ \ #define mod 998244353 //*/ typedef pair<int, int> P; #define INF (1LL << 60) void solve() { int K; cin >> K; if (K % 2 == 0) cout << -1 << endl; else { int t = 0; for (int i = 1;; i++) { t = t * 10 + 7; t %= K; if (t == 0) { cout << i << endl; return; } if (i > 100000000) { cout << -1 << endl; return; } } } } signed main() { cout << fixed << setprecision(18); cerr << fixed << setprecision(18); solve(); }
insert
83
83
83
87
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << '\n'; } if (k % 7 == 0) { k /= 7; } k *= 9; if (k == 9) { cout << 1 << '\n'; return 0; } long long cnt = 1; long long hehe = 10; while (hehe != 1) { hehe *= 10; hehe %= k; cnt++; } cout << cnt << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << '\n'; return 0; } if (k % 7 == 0) { k /= 7; } k *= 9; if (k == 9) { cout << 1 << '\n'; return 0; } long long cnt = 1; long long hehe = 10; while (hehe != 1) { hehe *= 10; hehe %= k; cnt++; } cout << cnt << '\n'; return 0; }
insert
9
9
9
10
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long int #define MOD 1000000007ll #define pb push_back #define vl vector<ll> #define pll pair<ll, ll> #define mp make_pair using namespace std; #define pi (long double)3.14159265358979323846 #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); struct sch { ll s, e, t; }; bool sortinrev(const struct sch &a, const struct sch &b) { return (a.s < b.s); } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } ll power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; // y = y/2 x = (x * x) % p; } return res; } int main() { ll x; cin >> x; if (x % 2 == 0) { cout << -1 << endl; return 0; } ll ans = 0; ll rem = 0; while (1) { rem *= 10; rem += 7; ans++; if (rem % x == 0) break; rem = rem % x; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define MOD 1000000007ll #define pb push_back #define vl vector<ll> #define pll pair<ll, ll> #define mp make_pair using namespace std; #define pi (long double)3.14159265358979323846 #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); struct sch { ll s, e, t; }; bool sortinrev(const struct sch &a, const struct sch &b) { return (a.s < b.s); } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } ll power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; // y = y/2 x = (x * x) % p; } return res; } int main() { ll x; cin >> x; if (x % 2 == 0) { cout << -1 << endl; return 0; } ll ans = 0; ll rem = 0; while (1) { rem *= 10; rem += 7; ans++; if (rem % x == 0) break; rem = rem % x; if (ans > 1000000) { cout << -1 << endl; return 0; } } cout << ans << endl; }
insert
51
51
51
55
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define repbit(bit, n) for (int bit = 0; bit < (1 << n); bit++) using namespace std; typedef long long ll; const int INF = 1001001001; // const ll INF = 1000000000000000000; int main() { int k; cin >> k; if (k % 2 == 0) { cout << -1 << endl; return 0; } int ans; vector<int> s; s.push_back(0); int id = 0; ll term = 7 % k; while (true) { int &ref = s.back(); if (id != 0 and ref == 0) { ans = id; break; } s.push_back((ref + term) % k); id++; term *= 10; term %= k; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define repbit(bit, n) for (int bit = 0; bit < (1 << n); bit++) using namespace std; typedef long long ll; const int INF = 1001001001; // const ll INF = 1000000000000000000; int main() { int k; cin >> k; if (k % 2 == 0 or k % 5 == 0) { cout << -1 << endl; return 0; } int ans; vector<int> s; s.push_back(0); int id = 0; ll term = 7 % k; while (true) { int &ref = s.back(); if (id != 0 and ref == 0) { ans = id; break; } s.push_back((ref + term) % k); id++; term *= 10; term %= k; } cout << ans << endl; return 0; }
replace
13
14
13
14
TLE
p02596
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; int dp[MAXN]; int main() { int k; cin >> k; dp[1] = 7 % k; if (dp[1] == 0) return cout << 1 << "\n", 0; for (int i = 2; i <= MAXN; i++) { dp[i] = (dp[1] + (dp[i - 1] * (10 % k)) % k) % k; if (dp[i] == 0) return cout << i << "\n", 0; } return cout << -1 << "\n", 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; int dp[MAXN]; int main() { int k; cin >> k; dp[1] = 7 % k; if (dp[1] == 0) return cout << 1 << "\n", 0; for (int i = 2; i < MAXN; i++) { dp[i] = (dp[1] + (dp[i - 1] * (10 % k)) % k) % k; if (dp[i] == 0) return cout << i << "\n", 0; } return cout << -1 << "\n", 0; }
replace
10
11
10
11
0
p02596
C++
Runtime Error
#include <iostream> int main() { int K; std::cin >> K; int m = 0; for (int i = 0; i < K; i++) { m = (m * 10 + 7 % K) % K; if (m == 0) { std::cout << i + 1 << std::endl; exit(1); } } std::cout << -1 << std::endl; }
#include <iostream> int main() { int K; std::cin >> K; int m = 0; for (int i = 0; i < K; i++) { m = (m * 10 + 7 % K) % K; if (m == 0) { std::cout << i + 1 << std::endl; exit(0); } } std::cout << -1 << std::endl; }
replace
10
11
10
11
1
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <cmath> using ll = long long; using namespace std; stack<int> st; queue<int> qu; queue<pair<int, int>> qu2; priority_queue<int> pq; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, n) for (int i = 1; i <= (int)(n); i++) #define mins(x, y) x = min(x, y) #define maxs(x, y) x = max(x, y) typedef set<int> set_t; typedef set<string> set_g; typedef complex<double> xy_t; static const int NIL = -1; static const int INF = 1000000007; #define mp make_pair #define sz(x) int(x.sise()) #define mod 1000000007 #define reps(i, s, n) for (int i = s; i < n; i++) #define Rreps(i, n, e) for (int i = n - 1; i >= e; --i) #define Rrep(i, n) Rreps(i, n, 0) deque<int> deq; #define fi first #define se second // const ll MOD = 998244353; const ll MOD = (1e+9) + 7; typedef pair<int, int> P; int main() { int k; cin >> k; ll s = 7; ll ans = 1; while (1) { if (s % k == 0) { cout << ans << endl; return 0; } else { s %= k; s = s * 10 + 7; ans++; } if (k % 2 == 0) { break; } if (ans > INF) { break; } } cout << -1 << endl; return 0; }
#include <bits/stdc++.h> #include <cmath> using ll = long long; using namespace std; stack<int> st; queue<int> qu; queue<pair<int, int>> qu2; priority_queue<int> pq; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, n) for (int i = 1; i <= (int)(n); i++) #define mins(x, y) x = min(x, y) #define maxs(x, y) x = max(x, y) typedef set<int> set_t; typedef set<string> set_g; typedef complex<double> xy_t; static const int NIL = -1; static const int INF = 1000000007; #define mp make_pair #define sz(x) int(x.sise()) #define mod 1000000007 #define reps(i, s, n) for (int i = s; i < n; i++) #define Rreps(i, n, e) for (int i = n - 1; i >= e; --i) #define Rrep(i, n) Rreps(i, n, 0) deque<int> deq; #define fi first #define se second // const ll MOD = 998244353; const ll MOD = (1e+9) + 7; typedef pair<int, int> P; int main() { int k; cin >> k; ll s = 7; ll ans = 1; while (1) { if (s % k == 0) { cout << ans << endl; return 0; } else { s %= k; s = s * 10 + 7; ans++; } if (k % 2 == 0) { break; } if (ans > k + 1) { break; } } cout << -1 << endl; return 0; }
replace
46
47
46
47
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define INF LONG_LONG_MAX #define int long long #define ar array #define db double #define pi 3.14159265358979323846 #define pow pw int pw(int a, int b) { int ans = 1; while (b) { if (b % 2) ans *= a; a *= a; b /= 2; } return (ans); } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int k; cin >> k; int ans = 0, du = 0; do { ans++; du = (du * 10 + 7) % k; } while (du); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #define INF LONG_LONG_MAX #define int long long #define ar array #define db double #define pi 3.14159265358979323846 #define pow pw int pw(int a, int b) { int ans = 1; while (b) { if (b % 2) ans *= a; a *= a; b /= 2; } return (ans); } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int k; cin >> k; int ans = 0, du = 0; do { ans++; du = (du * 10 + 7) % k; if (ans > k) { cout << -1; return 0; } } while (du); cout << ans; return 0; }
insert
28
28
28
32
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(), (v).end() 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) { a = b; return 1; } return 0; } const ll INF = 1LL << 60; const int inf = (1 << 30) - 1; const int mod = 1e9 + 7; int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1}; int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1}; int main() { cin.tie(0); ios::sync_with_stdio(false); int k; cin >> k; if (k == 2 || k == 5) { cout << -1 << endl; return 0; } ll t = 7; int cnt = 1; while (t % k != 0) { t = (t * 10 + 7) % k; cnt++; } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(), (v).end() 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) { a = b; return 1; } return 0; } const ll INF = 1LL << 60; const int inf = (1 << 30) - 1; const int mod = 1e9 + 7; int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1}; int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1}; int main() { cin.tie(0); ios::sync_with_stdio(false); int k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { cout << -1 << endl; return 0; } ll t = 7; int cnt = 1; while (t % k != 0) { t = (t * 10 + 7) % k; cnt++; } cout << cnt << endl; }
replace
33
34
33
34
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long k; cin >> k; if (k % 2 == 0) { return cout << "-1\n", 0; } int cur = 7 % k; int ans = 1; while (cur != 0) { cur = cur * 10 + 7; cur %= k; ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long k; cin >> k; if (k % 2 == 0 || k % 5 == 0) { return cout << "-1\n", 0; } int cur = 7 % k; int ans = 1; while (cur != 0) { cur = cur * 10 + 7; cur %= k; ans++; } cout << ans << endl; }
replace
7
8
7
8
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; if (k % 2 == 0) { cout << "-1"; return 0; } int p = 0, c = 0; while (1 == 1) { c++; p = (p * 10 + 7) % k; if (p == 0) { break; } } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; if (k % 2 == 0) { cout << "-1"; return 0; } if (k % 5 == 0) { cout << "-1"; return 0; } int p = 0, c = 0; while (1 == 1) { c++; p = (p * 10 + 7) % k; if (p == 0) { break; } } cout << c; return 0; }
insert
6
6
6
10
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; int cnt = 0, now = 0; auto start = chrono::system_clock::now(); while (++cnt) { now = (now * 10 + 7) % K; if (now == 0) return cout << cnt << "\n", 0; if (static_cast<double>(chrono::duration_cast<chrono::microseconds>( chrono::system_clock::now() - start) .count() / 1000.0) > 1999) return cout << -1 << "\n", 0; } }
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; int cnt = 0, now = 0; auto start = chrono::system_clock::now(); while (++cnt) { now = (now * 10 + 7) % K; if (now == 0) return cout << cnt << "\n", 0; if (static_cast<double>(chrono::duration_cast<chrono::microseconds>( chrono::system_clock::now() - start) .count() / 1000.0) > 1990) return cout << -1 << "\n", 0; } }
replace
15
16
15
16
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; int main() { int K; cin >> K; auto start = system_clock::now(); for (int cnt = 1, now = 0; static_cast<double>( duration_cast<milliseconds>(system_clock::now() - start).count()) < 1999; cnt++) { now = (now * 10 + 7) % K; if (now == 0) return cout << cnt << "\n", 0; } cout << -1 << "\n"; }
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; int main() { int K; cin >> K; auto start = system_clock::now(); for (int cnt = 1, now = 0; static_cast<double>( duration_cast<milliseconds>(system_clock::now() - start).count()) < 1990; cnt++) { now = (now * 10 + 7) % K; if (now == 0) return cout << cnt << "\n", 0; } cout << -1 << "\n"; }
replace
11
12
11
12
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll k; ll num = 7; cin >> k; ll sum = 7LL % k; ll fac = 10LL % k; if (k % 2 != 0 && k != 5) { ll cnt = 1; while (sum % k) { sum += (num % k * fac) % k; num = (num % k * fac); cnt++; } cout << cnt << endl; } else { cout << -1 << endl; } }
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll k; ll num = 7; cin >> k; ll sum = 7LL % k; ll fac = 10LL % k; ll cnt = 1; while (sum % k && cnt <= 10000000) { sum += (num % k * fac) % k; num = num % k * fac; cnt++; } if (sum % k == 0) { cout << cnt << endl; } else { cout << -1 << endl; } }
replace
9
16
9
16
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; if ((K % 2 == 0) || (K % 5 == 0)) { cout << -1 << endl; } else { if (K % 7 == 0) { K /= 7; } int mod = 9 * K; int x = 1 % 9 * K; for (int i = 1;; i++) { x = (x * (10 % mod)) % mod; if (x == 1) { cout << i << endl; return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; if ((K % 2 == 0) || (K % 5 == 0)) { cout << -1 << endl; } else { if (K % 7 == 0) { K /= 7; } int mod = 9 * K; int x = 1 % (9 * K); for (int i = 1;; i++) { x = (x * (10 % mod)) % mod; if (x == 1) { cout << i << endl; return 0; } } } return 0; }
replace
13
14
13
14
TLE
p02596
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; long long MOD = 1000000007LL; const double PI = 3.14159265358979323846; #undef INT_MIN #undef INT_MAX #define INT_MIN -2147483648 #define INT_MAX 2147483647 #define endl "\n" int main() { string s; cin >> s; int K = stoi(s); if (K % 2 == 0) { cout << -1 << endl; return 0; } int count = s.length(); int seven = 7; for (int j = 1; j < count; ++j) { seven = seven * 10 + 7; } if (seven < K) { seven = seven * 10 + 7; ++count; } long long preAmari = seven % K; for (int i = 0;; ++i) { if (preAmari % K == 0) { cout << count + i << endl; return 0; } preAmari = (preAmari * 10 + 7) % K; } return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; long long MOD = 1000000007LL; const double PI = 3.14159265358979323846; #undef INT_MIN #undef INT_MAX #define INT_MIN -2147483648 #define INT_MAX 2147483647 #define endl "\n" int main() { string s; cin >> s; int K = stoi(s); if (K % 2 == 0 || K % 5 == 0) { cout << -1 << endl; return 0; } int count = s.length(); int seven = 7; for (int j = 1; j < count; ++j) { seven = seven * 10 + 7; } if (seven < K) { seven = seven * 10 + 7; ++count; } long long preAmari = seven % K; for (int i = 0;; ++i) { if (preAmari % K == 0) { cout << count + i << endl; return 0; } preAmari = (preAmari * 10 + 7) % K; } return 0; }
replace
24
25
24
25
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int64_t MOD = 1000000007; double PI = 3.141592653589793; int main() { int K; cin >> K; if (K % 2 == 0 || K % 2 == 5) cout << -1; else { int tmp = 7, ans = 1; while (true) { if (tmp % K == 0) { cout << ans; break; } else { ans++; tmp = (tmp * 10 + 7) % K; } } } }
#include <bits/stdc++.h> using namespace std; int64_t MOD = 1000000007; double PI = 3.141592653589793; int main() { int K; cin >> K; if (K % 2 == 0 || K % 5 == 0) cout << -1; else { int tmp = 7, ans = 1; while (true) { if (tmp % K == 0) { cout << ans; break; } else { ans++; tmp = (tmp * 10 + 7) % K; } } } }
replace
9
10
9
10
TLE
p02596
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long int K; cin >> K; long long int N = 7; long long int i = 1; long long int output = -1; if (K % 2 == 0) { cout << output << '\n'; return 0; } while (i < LLONG_MAX) { if (N % K == 0) { output = i; break; } N %= K; N = 10 * N + 7; i += 1; } cout << output << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { long long int K; cin >> K; long long int N = 7; long long int i = 1; long long int output = -1; if (K % 2 == 0) { cout << output << '\n'; return 0; } while (i < 7 * K + 1) { if (N % K == 0) { output = i; break; } N %= K; N = 10 * N + 7; i += 1; } cout << output << '\n'; }
replace
15
16
15
16
TLE