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
p02546
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int main() { char S[256]; cin >> S; int len = strlen(S); if (S[len - 1] != 's') cout << S << "s"; if (S[len - 1] == 's') cout << S << "es"; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int main() { char s[1000]; cin >> s; int len = strlen(s); if (s[len - 1] != 's') cout << s << "s"; else if (s[len - 1] == 's') cout << s << "es"; return 0; }
replace
7
14
7
14
0
p02546
C++
Runtime Error
#include <bits/stdc++.h> #include <fstream> #include <iostream> using namespace std; void change_to_plural(char *input_string, char *output_string) { int n; n = strlen(input_string); if (input_string[n - 1] == 's') { input_string[n] = 'e'; input_string[n + 1] = 's'; input_string[n + 2] = '\0'; } else { input_string[n] = 's'; input_string[n + 1] = '\0'; } output_string = input_string; n = strlen(input_string); for (int i = 0; i < n; i++) cout << output_string[i]; } int main() { char in[10], out[10]; cin >> in; change_to_plural(in, out); cout << endl; }
#include <bits/stdc++.h> #include <fstream> #include <iostream> using namespace std; void change_to_plural(char *input_string, char *output_string) { int n; n = strlen(input_string); if (input_string[n - 1] == 's') { input_string[n] = 'e'; input_string[n + 1] = 's'; input_string[n + 2] = '\0'; } else { input_string[n] = 's'; input_string[n + 1] = '\0'; } output_string = input_string; n = strlen(input_string); for (int i = 0; i < n; i++) cout << output_string[i]; } int main() { char in[1000], out[1000]; cin >> in; change_to_plural(in, out); cout << endl; }
replace
28
29
28
29
0
p02546
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string s; scanf("%s", &s); if (s[s.size() - 1] == 's') cout << s << "es" << endl; else cout << s << 's' << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; if (s[s.size() - 1] == 's') cout << s << "es" << endl; else cout << s << 's' << endl; return 0; }
replace
4
5
4
5
-11
p02546
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { string X; cin >> X; if (X.at(-1) == 's') { cout << X << "es" << endl; } else { cout << X << "s" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { string X; cin >> X; char a = X[X.size() - 1]; if (a == 's') { cout << X << "es" << endl; } else { cout << X << "s" << endl; } }
replace
6
7
6
9
-6
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at: __n (which is 18446744073709551615) >= this->size() (which is 5)
p02547
C++
Runtime Error
#include <bits/stdc++.h> #define int long long #define fastio \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); using namespace std; void solve() { deque<pair<int, int>> v; int n, cnt = 0; cin >> n; bool ok = false; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; if (x == y) cnt++; if (i >= 3) { if (v[0].first == v[0].second) cnt--; v.pop_front(); } if (cnt == 3) { ok = true; } } cout << (ok ? "Yes\n" : "No\n"); } signed main() { fastio int t = 1; // cin >> t; while (t--) solve(); }
#include <bits/stdc++.h> #define int long long #define fastio \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); using namespace std; void solve() { deque<pair<int, int>> v; int n, cnt = 0; cin >> n; bool ok = false; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; v.emplace_back(x, y); if (x == y) cnt++; if (i >= 3) { if (v[0].first == v[0].second) cnt--; v.pop_front(); } if (cnt == 3) { ok = true; } } cout << (ok ? "Yes\n" : "No\n"); } signed main() { fastio int t = 1; // cin >> t; while (t--) solve(); }
insert
18
18
18
19
0
p02547
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5 + 13; int a[maxn]; int b[maxn]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", &a[i], &b[i]); } for (int i = 1; i <= n - 2; i++) { int cnt = 0; for (int j = 0; j < 3; j++) { if (a[i + j] == b[i + j]) { cnt++; } } if (cnt == 3) { return printf("Yes"); } } printf("No"); }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5 + 13; int a[maxn]; int b[maxn]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", &a[i], &b[i]); } for (int i = 1; i <= n - 2; i++) { int cnt = 0; for (int j = 0; j < 3; j++) { if (a[i + j] == b[i + j]) { cnt++; } } if (cnt == 3) { return printf("Yes"), 0; } } printf("No"); }
replace
21
22
21
22
3
p02547
C++
Runtime Error
#include <algorithm> #include <cmath> #include <fstream> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using namespace std; struct XX { int s; int e; }; class xxGreater { public: bool operator()(const XX &riLeft, const XX &riRight) const { // 第2条件 if ((riLeft.s) == (riRight.s)) { return riLeft.e < riRight.e; //<:昇順(小さいものから順番)、>:降順(大きいものから順番) // プライオリティキューの場合は > // で、top()すると値の小さいものがとれる } // 第1条件 return (riLeft.s) > (riRight.s); } }; int main(int argc, const char *argv[]) { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> ans; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; if (a == b) { ans.push_back(i); } } int f = 0; for (int i = 0; i < n - 2; i++) { if (ans[i + 2] - ans[i + 1] == 1 && ans[i + 1] - ans[i] == 1) { f = 1; } } if (f == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
#include <algorithm> #include <cmath> #include <fstream> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using namespace std; struct XX { int s; int e; }; class xxGreater { public: bool operator()(const XX &riLeft, const XX &riRight) const { // 第2条件 if ((riLeft.s) == (riRight.s)) { return riLeft.e < riRight.e; //<:昇順(小さいものから順番)、>:降順(大きいものから順番) // プライオリティキューの場合は > // で、top()すると値の小さいものがとれる } // 第1条件 return (riLeft.s) > (riRight.s); } }; int main(int argc, const char *argv[]) { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> ans; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; if (a == b) { ans.push_back(i); } } int f = 0; if (ans.size() > 2) { for (int i = 0; i < n - 2; i++) { if (ans[i + 2] - ans[i + 1] == 1 && ans[i + 1] - ans[i] == 1) { f = 1; } } } if (f == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
replace
52
55
52
57
0
p02547
C++
Runtime Error
#include <algorithm> #include <iostream> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string> #include <vector> static const int MAX = 100000; static const int INFTY = (1 << 20); using namespace std; int main() { int N; cin >> N; vector<vector<int>> d(N); for (int i = 0; i < N; i++) { cin >> d[i][0]; cin >> d[i][1]; } int count = 0; for (int i = 0; i < N; i++) { if (d[i][0] == d[i][1]) count++; else count = 0; if (count >= 3) { printf("Yes"); return 0; } } printf("No"); return 0; }
#include <algorithm> #include <iostream> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string> #include <vector> static const int MAX = 100000; static const int INFTY = (1 << 20); using namespace std; int main() { int N; cin >> N; vector<vector<int>> d(N, vector<int>(2)); for (int i = 0; i < N; i++) { cin >> d[i][0]; cin >> d[i][1]; } int count = 0; for (int i = 0; i < N; i++) { if (d[i][0] == d[i][1]) count++; else count = 0; if (count >= 3) { printf("Yes"); return 0; } } printf("No"); return 0; }
replace
16
17
16
17
-11
p02547
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define endl "\n" typedef long long int lli; #define optimize \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define vi vector<int> #define pii pair<int, int> #define mii map<int, int> #define F first #define S second #define forn(i, n) for (int i = 0; i < n; i++) #define forab(i, a, b) for (int i = a; i < b; i++) #define forll(i, a, b) for (lli i = a; i < b; i++) #define mp make_pair #define pb push_back #define sortv(v) sort(v.begin(), v.end()) #define debug(x) cout << #x << " : " << x << endl #define all(x) x.begin(), x.end() #define printv(v) \ for (auto it : v) \ cout << it << " "; \ cout << endl; #define prec(n) fixed << setprecision(n) const lli mod = 1000000007; const int mod2 = 998244353; const int N = 1e5; template <typename T> T power(T base, T exp) { T res = 1; while (exp > 0) { if (exp & 1) res = (res % mod * base % mod) % mod; base = (base % mod * base % mod) % mod; exp >>= 1; } return res; } int main() { optimize #ifndef ONLINE_JUDGE freopen("inputf.in", "r", stdin); freopen("outputf.in", "w", stdout); #endif int n; cin >> n; vi d; int u, v; forn(i, n) { cin >> u >> v; if (u == v) d.pb(i); } int ans = 0; for (int i = 1; i < d.size() - 1; i++) { if (d[i - 1] == d[i] - 1 && d[i] + 1 == d[i + 1]) ans = 1; } if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define endl "\n" typedef long long int lli; #define optimize \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define vi vector<int> #define pii pair<int, int> #define mii map<int, int> #define F first #define S second #define forn(i, n) for (int i = 0; i < n; i++) #define forab(i, a, b) for (int i = a; i < b; i++) #define forll(i, a, b) for (lli i = a; i < b; i++) #define mp make_pair #define pb push_back #define sortv(v) sort(v.begin(), v.end()) #define debug(x) cout << #x << " : " << x << endl #define all(x) x.begin(), x.end() #define printv(v) \ for (auto it : v) \ cout << it << " "; \ cout << endl; #define prec(n) fixed << setprecision(n) const lli mod = 1000000007; const int mod2 = 998244353; const int N = 1e5; template <typename T> T power(T base, T exp) { T res = 1; while (exp > 0) { if (exp & 1) res = (res % mod * base % mod) % mod; base = (base % mod * base % mod) % mod; exp >>= 1; } return res; } int main() { optimize #ifndef ONLINE_JUDGE freopen("inputf.in", "r", stdin); freopen("outputf.in", "w", stdout); #endif int n; cin >> n; vi d; int u, v; forn(i, n) { cin >> u >> v; if (u == v) d.pb(i); } int ans = 0; if (d.size() >= 3) { for (int i = 1; i < d.size() - 1; i++) { if (d[i - 1] == d[i] - 1 && d[i] + 1 == d[i + 1]) ans = 1; } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
replace
61
64
61
66
TLE
p02547
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pint pair<int, int> #define pll pair<ll, ll> #define vint vector<int> #define vll vector<ll> #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) const int INF = 100100100; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vint D1(n), D2(n); int check = 0; int is_yes = 0; REP(i, n) { cin >> D1[n] >> D2[n]; if (D1[n] == D2[n]) { check++; } else { check = 0; } if (check == 3) { is_yes = 1; } } if (is_yes) { cout << "Yes\n"; } else { cout << "No\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pint pair<int, int> #define pll pair<ll, ll> #define vint vector<int> #define vll vector<ll> #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) const int INF = 100100100; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vint D1(n), D2(n); int check = 0; int is_yes = 0; REP(i, n) { cin >> D1[i] >> D2[i]; if (D1[i] == D2[i]) { check++; } else { check = 0; } if (check == 3) { is_yes = 1; } } if (is_yes) { cout << "Yes\n"; } else { cout << "No\n"; } return 0; }
replace
23
25
23
25
0
p02547
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> ds; for (auto &p : ds) cin >> p.first >> p.second; bool ok = false; for (int i = 0; i < n - 2; ++i) { if (ds[i].first == ds[i].second && ds[i + 1].first == ds[i + 1].second && ds[i + 2].first == ds[i + 2].second) { ok |= 1; } } cout << (ok ? "Yes\n" : "No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> ds(n); for (auto &p : ds) cin >> p.first >> p.second; bool ok = false; for (int i = 0; i < n - 2; ++i) { if (ds[i].first == ds[i].second && ds[i + 1].first == ds[i + 1].second && ds[i + 2].first == ds[i + 2].second) { ok |= 1; } } cout << (ok ? "Yes\n" : "No\n"); return 0; }
replace
6
7
6
7
-11
p02547
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int d11, d12, d21, d22, d31, d32; string s = "No"; cin >> d11 >> d12 >> d21 >> d22; for (int i = 0; n - 2; i++) { int a, b; cin >> a >> b; if (i > 0) { d11 = d21; d12 = d22; d21 = d31; d22 = d32; d31 = a; d32 = b; } else { d31 = a; d32 = b; } if (d11 == d12 && d21 == d22 && d31 == d32) { s = "Yes"; } } cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int d11, d12, d21, d22, d31, d32; string s = "No"; cin >> d11 >> d12 >> d21 >> d22; for (int i = 0; i < n - 2; i++) { int a, b; cin >> a >> b; if (i > 0) { d11 = d21; d12 = d22; d21 = d31; d22 = d32; d31 = a; d32 = b; } else { d31 = a; d32 = b; } if (d11 == d12 && d21 == d22 && d31 == d32) { s = "Yes"; } } cout << s << endl; return 0; }
replace
9
10
9
10
TLE
p02547
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair<ll, ll>; string char_to_string(char val) { return string(1, val); } int char_to_int(char val) { return val - '0'; } 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; } struct edge { ll to, cost; }; int main() { int n; cin >> n; vector<vector<int>> d(n, vector<int>(2)); for (int i = 0; i < n; i++) { cin >> d[i][0] >> d[i][1]; } bool flag = false; for (int i = 0; i <= n - 2; i++) { if (d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]) { flag = true; break; } } if (flag == true) cout << "Yes" << endl; else cout << "No" << endl; }
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair<ll, ll>; string char_to_string(char val) { return string(1, val); } int char_to_int(char val) { return val - '0'; } 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; } struct edge { ll to, cost; }; int main() { int n; cin >> n; vector<vector<int>> d(n, vector<int>(2)); for (int i = 0; i < n; i++) { cin >> d[i][0] >> d[i][1]; } bool flag = false; for (int i = 0; i <= n - 3; i++) { if (d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]) { flag = true; break; } } if (flag == true) cout << "Yes" << endl; else cout << "No" << endl; }
replace
35
36
35
36
0
p02547
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long int #define fir first #define sec second #define MOD 1000000007 #define vvi vector<vector<int>> #define vvs vector<vector<string>> #define gcd(a, b) __gcd(a, b) #define lcm(a, b) (a * b) / gcd(a, b) #define pb push_back #define vi vector<int> #define test(t) \ int t; \ cin >> t; \ while (t--) #define vl vector<ll> #define vb vector<bool> #define vs vector<string> #define vvl vector<vl> #define loopin(i, n) for (int i = 0; i < (n); i++) #define loopdec(i, n) for (int i = n - 1; i >= 0; i--) const int mod = 1e9 + 7; void solve() { int n; cin >> n; int a[10][10]; for (int i = 0; i < n; i++) { cin >> a[i][0]; cin >> a[i][1]; } int count = 0; for (int i = 0; i < n; i++) { if (a[i][0] == a[i][1]) { count++; } else { count = 0; } if (count >= 3) { cout << "Yes" << endl; return; } } cout << "No" << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define fir first #define sec second #define MOD 1000000007 #define vvi vector<vector<int>> #define vvs vector<vector<string>> #define gcd(a, b) __gcd(a, b) #define lcm(a, b) (a * b) / gcd(a, b) #define pb push_back #define vi vector<int> #define test(t) \ int t; \ cin >> t; \ while (t--) #define vl vector<ll> #define vb vector<bool> #define vs vector<string> #define vvl vector<vl> #define loopin(i, n) for (int i = 0; i < (n); i++) #define loopdec(i, n) for (int i = n - 1; i >= 0; i--) const int mod = 1e9 + 7; void solve() { int n; cin >> n; int a[n + 1][10]; for (int i = 0; i < n; i++) { cin >> a[i][0]; cin >> a[i][1]; } int count = 0; for (int i = 0; i < n; i++) { if (a[i][0] == a[i][1]) { count++; } else { count = 0; } if (count >= 3) { cout << "Yes" << endl; return; } } cout << "No" << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }
replace
27
28
27
28
0
p02547
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<int>> s(n, vector<int>(2)); int ans = 0; for (int i = 0; i < n; i++) { for (int f = 0; f < 2; f++) { cin >> s.at(i).at(f); } } for (int i = 0; i < n; i++) { if (s.at(i).at(0) == s.at(i).at(1)) ans++; if (ans == 3) break; else if (s.at(i).at(0) != s.at(i).at(i)) ans = 0; } if (ans >= 3) cout << "Yes" << endl; else cout << "No" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<int>> s(n, vector<int>(2)); int ans = 0; for (int i = 0; i < n; i++) { for (int f = 0; f < 2; f++) { cin >> s.at(i).at(f); } } for (int i = 0; i < n; i++) { if (s.at(i).at(0) == s.at(i).at(1)) ans++; if (ans == 3) break; else if (s.at(i).at(0) != s.at(i).at(1)) ans = 0; } if (ans >= 3) cout << "Yes" << endl; else cout << "No" << endl; }
replace
18
19
18
19
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 2) >= this->size() (which is 2)
p02547
C++
Runtime Error
#include <iostream> using namespace std; int main() { int n, sum = 0; cin >> n; int a[2][n]; cin >> a[0][0] >> a[0][1] >> a[1][0] >> a[1][1]; for (int i = 2; i < n; i++) { cin >> a[i][0] >> a[i][1]; if (a[i - 2][1] == a[i - 2][0] && a[i - 1][1] == a[i - 1][0] && a[i][1] == a[i][0]) { sum++; cout << "Yes"; break; } } if (sum == 0) cout << "No"; return 0; }
#include <iostream> using namespace std; int main() { int n, sum = 0; cin >> n; int a[n][2]; cin >> a[0][0] >> a[0][1] >> a[1][0] >> a[1][1]; for (int i = 2; i < n; i++) { cin >> a[i][0] >> a[i][1]; if (a[i - 2][1] == a[i - 2][0] && a[i - 1][1] == a[i - 1][0] && a[i][1] == a[i][0]) { sum++; cout << "Yes"; break; } } if (sum == 0) cout << "No"; return 0; }
replace
5
6
5
6
0
p02547
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long int static const auto _____ = []() { // fast IO code : this I understand ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(0); return 0; }(); int main() { int n; cin >> n; int a[2][n]; int cnt = 0; int flag = 0; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; if (a[i][0] == a[i][1]) { cnt++; if (cnt == 3) flag = 1; } else cnt = 0; } if (flag) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long int static const auto _____ = []() { // fast IO code : this I understand ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(0); return 0; }(); int main() { int n; cin >> n; int a[n][2]; int cnt = 0; int flag = 0; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; if (a[i][0] == a[i][1]) { cnt++; if (cnt == 3) flag = 1; } else cnt = 0; } if (flag) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
replace
16
17
16
17
0
p02547
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, d[10][3]; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < 2; j++) { cin >> d[i][j]; } } bool flag = 0; for (int i = 0; i <= n - 3; i++) { if (d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]) { flag = 1; break; } } if (flag == 1) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d[110][3]; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < 2; j++) { cin >> d[i][j]; } } bool flag = 0; for (int i = 0; i <= n - 3; i++) { if (d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]) { flag = 1; break; } } if (flag == 1) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
replace
3
4
3
4
0
p02548
C++
Time Limit Exceeded
// warm heart, wagging tail,and a smile just for you! // ███████████ // ███╬╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬████╬╬╬╬╬╬███ // ███████████ // ██╬╬╬╬╬████╬╬████╬╬╬╬╬██ // █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██ // ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██ // ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██ // ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████ // █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██ // ██████████████ // ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████ // ███████ █████ // ███████████████████ // #include "bits/stdc++.h" using namespace std; #define INF (1 << 30) #define LINF (1LL << 60) #define fs first #define sc second #define int long long #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FOR2(i, a, b) for (int i = (a); i <= (b); ++i) #define RFOR(i, a, b) for (int i = (b - 1); i >= (a); --i) #define RFOR2(i, a, b) for (int i = (b); i >= (a); --i) #define REP(i, n) FOR(i, 0, (n)) #define REP2(i, n) FOR2(i, 0, (n)) #define RREP(i, n) RFOR(i, 0, (n)) #define RREP2(i, n) RFOR2(i, 0, (n)) #define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i, a, b) ((a) <= (i) && (i) < (b)) #define range2(i, a, b) ((a) <= (i) && (i) <= (b)) #define debug(x) cout << #x << " = " << (x) << endl #define SP << " " << template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true; } else return false; } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true; } else return false; } #define MSB(x) (63 - __builtin_clzll(x)) #define pcnt(x) (__builtin_popcountll(x)) #define parity(i, j) (i & (1LL << j)) typedef pair<int, int> P; typedef tuple<int, int, int> T; typedef vector<int> vec; typedef vector<vector<int>> mat; vector<int> divisor(const int n) { vector<int> ret; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return ret; } void solve() { int N; cin >> N; int ans = 0; FOR2(i, 1, N) { vec d = divisor(N - i); ans += d.size(); } cout << ans << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); int T = 1; // cin >> T; while (T--) solve(); return 0; }
// warm heart, wagging tail,and a smile just for you! // ███████████ // ███╬╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬████╬╬╬╬╬╬███ // ███████████ // ██╬╬╬╬╬████╬╬████╬╬╬╬╬██ // █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██ // ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██ // ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██ // ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████ // █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██ // ██████████████ // ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████ // ███████ █████ // ███████████████████ // #include "bits/stdc++.h" using namespace std; #define INF (1 << 30) #define LINF (1LL << 60) #define fs first #define sc second #define int long long #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FOR2(i, a, b) for (int i = (a); i <= (b); ++i) #define RFOR(i, a, b) for (int i = (b - 1); i >= (a); --i) #define RFOR2(i, a, b) for (int i = (b); i >= (a); --i) #define REP(i, n) FOR(i, 0, (n)) #define REP2(i, n) FOR2(i, 0, (n)) #define RREP(i, n) RFOR(i, 0, (n)) #define RREP2(i, n) RFOR2(i, 0, (n)) #define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i, a, b) ((a) <= (i) && (i) < (b)) #define range2(i, a, b) ((a) <= (i) && (i) <= (b)) #define debug(x) cout << #x << " = " << (x) << endl #define SP << " " << template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true; } else return false; } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true; } else return false; } #define MSB(x) (63 - __builtin_clzll(x)) #define pcnt(x) (__builtin_popcountll(x)) #define parity(i, j) (i & (1LL << j)) typedef pair<int, int> P; typedef tuple<int, int, int> T; typedef vector<int> vec; typedef vector<vector<int>> mat; vector<int> divisor(const int n) { vector<int> ret; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return ret; } void solve() { int N; cin >> N; int ans = 0; FOR2(i, 1, N) { ans += (N - 1) / i; } cout << ans << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); int T = 1; // cin >> T; while (T--) solve(); return 0; }
replace
87
91
87
88
TLE
p02548
C++
Time Limit Exceeded
// AC - C - A x B + C #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, r, i, j, d, s = 0; cin >> n; r = sqrt(n); for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) { d = n - (i * j); if (d > 0) s = s + 1; } cout << s << "\n"; return 0; }
// AC - C - A x B + C #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, r, i, j, d, s = 0; cin >> n; r = sqrt(n); for (i = 1; i <= n; i++) for (j = 1; j <= (n / i); j++) { d = n - (i * j); if (d > 0) s = s + 1; } cout << s << "\n"; return 0; }
replace
14
15
14
15
TLE
p02548
C++
Time Limit Exceeded
#ifndef DEBUG #pragma GCC optimize("O3,no-stack-protector") #pragma GCC optimize("unroll-loops") #if __cplusplus < 201703L #pragma GCC target("avx") #else #pragma GCC target("avx2") #endif #endif #define _USE_MATH_DEFINES #include <bits/stdc++.h> #define dump(x) cout << x << endl #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i) #define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i) #define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); typedef int64_t Int; typedef long double Ld; using namespace std; template <class T> using Graph = vector<vector<T>>; const Ld pi = M_PI; const Int MOD = 1000000007; const Int INF = 1LL << 62; Int Floor(Int a, Int b) { return (a - (a % b)) / b; } template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> inline T Gcd(T a, T b) { T c; while (b) { c = b; b = a % b; a = c; } return a; } Int Lcm(Int a, Int b) { if (a < b) { swap(a, b); } return a / Gcd(a, b) * b; } vector<Int> divisor(Int n) { vector<Int> ret; for (Int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Int n; cin >> n; Int ans = 1; for (Int i = 2; i < n; i++) { auto v = divisor(i); ans += v.size(); } cout << ans << endl; return 0; }
#ifndef DEBUG #pragma GCC optimize("O3,no-stack-protector") #pragma GCC optimize("unroll-loops") #if __cplusplus < 201703L #pragma GCC target("avx") #else #pragma GCC target("avx2") #endif #endif #define _USE_MATH_DEFINES #include <bits/stdc++.h> #define dump(x) cout << x << endl #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i) #define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i) #define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); typedef int64_t Int; typedef long double Ld; using namespace std; template <class T> using Graph = vector<vector<T>>; const Ld pi = M_PI; const Int MOD = 1000000007; const Int INF = 1LL << 62; Int Floor(Int a, Int b) { return (a - (a % b)) / b; } template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> inline T Gcd(T a, T b) { T c; while (b) { c = b; b = a % b; a = c; } return a; } Int Lcm(Int a, Int b) { if (a < b) { swap(a, b); } return a / Gcd(a, b) * b; } vector<Int> divisor(Int n) { vector<Int> ret; for (Int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Int n; cin >> n; vector<Int> d{ 93668, 201177, 313925, 430062, 548725, 669422, 791780, 915548, 1040630, 1166750, 1293935, 1421996, 1550902, 1680578, 1810953, 1942002, 2073666, 2205986, 2338763, 2472113, 2606008, 2740315, 2875085, 3010305, 3145958, 3281973, 3418435, 3555195, 3692338, 3829833, 3967622, 4105787, 4244274, 4382991, 4522065, 4661460, 4801042, 4940922, 5081120, 5221472, 5362138, 5503108, 5644159, 5785585, 5927210, 6069000, 6211021, 6353304, 6495814, 6638449, 6781292, 6924353, 7067636, 7211106, 7354711, 7498504, 7642514, 7786669, 7931004, 8075504, 8220199, 8364997, 8510049, 8655190, 8800484, 8945974, 9091590, 9237328, 9383292, 9529316, 9675504, 9821898, 9968324, 10114972, 10261748, 10408621, 10555635, 10702823, 10850034, 10997454, 11145096, 11292653, 11440411, 11588376, 11736313, 11884447, 12032740, 12181098, 12329547, 12478206, 12626845, 12775675, 12924562, 13073587, 13222720, 13372007, 13521286, 13670825, 13820360}; Int ans = 0; if (1 <= (n - 1) / 10000) { ans = d[((n - 1) / 10000) - 1]; } for (Int i = ((n - 1) / 10000) * 10000 + 1; i < n; i++) { ans += divisor(i).size(); } cout << ans << endl; return 0; }
replace
87
91
87
109
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <fstream> #include <iostream> #include <stdlib.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> llP; ll mod(ll a, ll b) { ll ret = a % b; if (ret < 0) ret += b; return ret; } ll modpow(ll a, ll b, ll c) { ll res = 1; while (b > 0) { if (b & 1) res = mod(res * a, c); a = mod(a * a, c); b >>= 1; } return res; } int GCD(int x, int y) { if (x < y) { swap(x, y); } while (x % y != 0) { int temp = x; x = y; y = temp % y; } return y; } int digitsum(int x) { int sum = 0; while (x > 0) { sum += (x % 10); x /= 10; } return sum; } int main() { int n; cin >> n; int ans = 0; for (int i = 1; i <= n - 1; i++) { int cnt = 0; int cur; for (int j = 1; j <= sqrt(i); j++) { if (i % j == 0) { cnt++; cur = j; } } if (cur * cur == i) cnt = 2 * cnt - 1; else cnt *= 2; ans += cnt; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #include <fstream> #include <iostream> #include <stdlib.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> llP; ll mod(ll a, ll b) { ll ret = a % b; if (ret < 0) ret += b; return ret; } ll modpow(ll a, ll b, ll c) { ll res = 1; while (b > 0) { if (b & 1) res = mod(res * a, c); a = mod(a * a, c); b >>= 1; } return res; } int GCD(int x, int y) { if (x < y) { swap(x, y); } while (x % y != 0) { int temp = x; x = y; y = temp % y; } return y; } int digitsum(int x) { int sum = 0; while (x > 0) { sum += (x % 10); x /= 10; } return sum; } int main() { int n; cin >> n; int ans = 0; for (int i = 1; i <= n - 1; i++) { ans += (n - 1) / i; } cout << ans << endl; return 0; }
replace
53
66
53
54
TLE
p02548
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i, n) for (ll i = 0; i < n; ++i) #define ocut cout #define ouct cout #define itn int struct Union { vector<ll> par; Union(ll a) { par = vector<ll>(a, -1); } ll find(ll a) { if (par[a] < 0) { return a; } else { return par[a] = find(par[a]); } } bool same(ll a, ll b) { return (find(a) == find(b)); } ll size(ll a) { return -par[find(a)]; } void unite(ll a, ll b) { ll c = find(a), d = find(b); if (c == d) return; if (size(c) < size(d)) { swap(c, d); } par[c] += par[d]; par[d] = c; } }; ll euclidean_gcd(ll a, ll b) { if (a < b) return euclidean_gcd(b, a); ll r; while ((r = a % b)) { a = b; b = r; } return b; } ll euclidean_lcm(ll a, ll b) { return a / euclidean_gcd(a, b) * b; } ll binary(ll bina) { ll ans = 0; for (ll i = 0; bina > 0; i++) { ans += bina % 2; bina = bina / 2; } return ans; } void revStr(char *str) { int size = strlen(str); int i, j; char tmp = {0}; for (i = 0, j = size - 1; i < size / 2; i++, j--) { tmp = str[i]; str[i] = str[j]; str[j] = tmp; } return; } const int MAX = 510000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main(void) { ll n, s = 0; cin >> n; rep(i, n - 1) { s += (n - 1) / i; } cout << s; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i, n) for (ll i = 0; i < n; ++i) #define ocut cout #define ouct cout #define itn int struct Union { vector<ll> par; Union(ll a) { par = vector<ll>(a, -1); } ll find(ll a) { if (par[a] < 0) { return a; } else { return par[a] = find(par[a]); } } bool same(ll a, ll b) { return (find(a) == find(b)); } ll size(ll a) { return -par[find(a)]; } void unite(ll a, ll b) { ll c = find(a), d = find(b); if (c == d) return; if (size(c) < size(d)) { swap(c, d); } par[c] += par[d]; par[d] = c; } }; ll euclidean_gcd(ll a, ll b) { if (a < b) return euclidean_gcd(b, a); ll r; while ((r = a % b)) { a = b; b = r; } return b; } ll euclidean_lcm(ll a, ll b) { return a / euclidean_gcd(a, b) * b; } ll binary(ll bina) { ll ans = 0; for (ll i = 0; bina > 0; i++) { ans += bina % 2; bina = bina / 2; } return ans; } void revStr(char *str) { int size = strlen(str); int i, j; char tmp = {0}; for (i = 0, j = size - 1; i < size / 2; i++, j--) { tmp = str[i]; str[i] = str[j]; str[j] = tmp; } return; } const int MAX = 510000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main(void) { ll n, s = 0; cin >> n; rep(i, n) { if (i > 0) s = s + (n - 1) / i; } cout << s; }
replace
93
94
93
97
-8
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define Int int64_t using namespace std; int main() { Int N; cin >> N; Int ans = 0; for (Int C = 1; C < N; ++C) { Int n = N - C; for (Int A = 1; A * A <= n; ++A) { if (n % A != 0) { continue; } if (A * A == n) { ans += 1; } else { ans += 2; } } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> #define Int int64_t using namespace std; int main() { Int N; cin >> N; Int ans = 0; for (int a = 1; a <= N; ++a) { for (int b = 1; a * b < N; ++b) { ++ans; } } cout << ans << "\n"; return 0; }
replace
10
21
10
13
TLE
p02548
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; using P = pair<int, int>; vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return ret; } int main() { ll N; cin >> N; ll ans = 0; for (ll c = 1; c < N; c++) { ll M = N - c; ans += divisor(M).size(); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; using P = pair<int, int>; vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return ret; } int main() { ll N; cin >> N; ll ans = 0; for (ll a = 1; a < N; a++) { ans += (N - 1) / a; } cout << ans << endl; return 0; }
replace
26
29
26
28
TLE
p02548
C++
Time Limit Exceeded
// abc179_c #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <type_traits> #include <typeindex> #include <unordered_map> #include <unordered_set> #endif template <typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; } template <typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; } const double PI = acos(-1); const double EPS = 1e-9; int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10; int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int N; ll cnt = 0; cin >> N; for (int i = 1; i <= N; ++i) { for (int j = 1; j <= N; ++j) { int c = N - i * j; if (c > 0) cnt++; } } cout << cnt << endl; return 0; }
// abc179_c #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <type_traits> #include <typeindex> #include <unordered_map> #include <unordered_set> #endif template <typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; } template <typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; } const double PI = acos(-1); const double EPS = 1e-9; int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10; int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int N; ll cnt = 0; cin >> N; for (int i = 1; i <= N; ++i) { for (int j = 1; j <= N; ++j) { int c = N - i * j; if (c > 0) cnt++; else break; } } cout << cnt << endl; return 0; }
insert
82
82
82
84
TLE
p02548
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N; cin >> N; int ans = 0; for (int i = 1; i < N; i++) { int x = N - i; for (int j = 1; j * j <= x; j++) { if (x % j == 0) ans += 2; if (j * j == x) ans--; } } cout << ans; return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N; cin >> N; int ans = 0; for (int a = 1; a < N; a++) { ans += N / a; if (N % a == 0) ans--; } cout << ans; return 0; }
replace
10
18
10
14
TLE
p02548
C++
Time Limit Exceeded
// It's really tough #include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) x.begin(), x.end() #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define endl "\n" #define mem(x, y) memset(x, y, sizeof(x)) #define pb push_back #define mp make_pair #define fir first #define sec second const int N = 2e5 + 5; const ll inf = 9e18 + 9; const int mod = 1e9 + 7; ll res; void solve() { int n; cin >> n; for (int c = n - 1; c >= 1; c--) { int left = n - c; for (int a = 1; a <= left; a++) { int b; if (left % a == 0) { b = left / a; } if (a && b && c && ((a * b) + c == n)) { res++; } } } cout << res << endl; } int main() { IOS; ll t = 1; // cin>>t; for (int i = 1; i <= t; i++) { solve(); } }
// It's really tough #include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) x.begin(), x.end() #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define endl "\n" #define mem(x, y) memset(x, y, sizeof(x)) #define pb push_back #define mp make_pair #define fir first #define sec second const int N = 2e5 + 5; const ll inf = 9e18 + 9; const int mod = 1e9 + 7; ll res; void solve() { int n; cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; i * j < n; j++) { res++; } } cout << res << endl; } int main() { IOS; ll t = 1; // cin>>t; for (int i = 1; i <= t; i++) { solve(); } }
replace
23
33
23
26
TLE
p02548
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <deque> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define pb push_back #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, n, s) for (int i = (s); i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define rreps(i, n, s) for (int i = s; i >= n; i--) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } using ll = long long; using namespace std; constexpr long long MAX = 5100000; constexpr long long INF = 1LL << 60; constexpr int MOD = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; int cnt = 0; reps(c, n, 1) { reps(b, n, 1) { double a = (n - c) / (double)b; if (a > 0 && ceil(a) == floor(a)) { cnt++; } } } cout << cnt << endl; return 0; }
#include <algorithm> #include <cmath> #include <deque> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define pb push_back #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, n, s) for (int i = (s); i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define rreps(i, n, s) for (int i = s; i >= n; i--) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } using ll = long long; using namespace std; constexpr long long MAX = 5100000; constexpr long long INF = 1LL << 60; constexpr int MOD = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; int cnt = 0; int same = 0; reps(a, sqrt(n), 1) { reps(b, n, a) { if (a * b < n) { if (a == b) cnt++; else cnt += 2; } } } cout << cnt << endl; return 0; }
replace
42
47
42
50
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define int long long #define endl '\n' #define mod 1000000007 #define inf 1e18 #define PI 3.14159265358979323846264338327950L #define w(x) \ int x; \ cin >> x; \ while (x--) using namespace std; bool sieve[2000006]; void sieve_make() { memset(sieve, true, sizeof(sieve)); sieve[0] = sieve[1] = false; for (int i = 2; i * i < 2000006; i++) { if (sieve[i]) { for (int j = i * i; j < 2000006; j += i) sieve[j] = false; } } } int max(int a, int b) { if (a > b) return a; return b; } int min(int a, int b) { if (a < b) return a; return b; } int modexp(int a, int b, int c) { if (a == 0) return 0; if (b == 0) return 1; int ans; if (b % 2 == 0) { int small = modexp(a, b / 2, c); ans = (small * small) % c; } else { int small = modexp(a, b - 1, c); ans = (a % c); ans = (small * ans) % c; } return (ans + c) % c; } bool sign(int x) { if (x > 0) return true; return false; } int kadane(int *a, int n) { int loc = a[0], glo = a[0]; for (int i = 1; i < n; i++) { loc = max(a[i], loc + a[i]); glo = max(glo, loc); } return glo; } int dp[100005]; int dfs(vector<int> *adj, int sv, bool col, bool *vis, int n) { if (sv == n - 1) return 1; int ans = 0; for (auto i : adj[sv]) { if (!vis[i]) { vis[i] = 1; if (col) ans += dfs(adj, i, !col, vis, n); else ans += dfs(adj, i, !col, vis, n) + dfs(adj, i, col, vis, n); vis[i] = 0; } } return ans; } int32_t main() { ios::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int ans = 0; for (int i = 1; i < n; i++) { int temp = n - i, j; for (j = 1; j * j <= temp; j++) { if (j * j == temp) ans++; else if (temp % j == 0) ans += 2; } } cout << ans << endl; }
#include <bits/stdc++.h> #define int long long #define endl '\n' #define mod 1000000007 #define inf 1e18 #define PI 3.14159265358979323846264338327950L #define w(x) \ int x; \ cin >> x; \ while (x--) using namespace std; bool sieve[2000006]; void sieve_make() { memset(sieve, true, sizeof(sieve)); sieve[0] = sieve[1] = false; for (int i = 2; i * i < 2000006; i++) { if (sieve[i]) { for (int j = i * i; j < 2000006; j += i) sieve[j] = false; } } } int max(int a, int b) { if (a > b) return a; return b; } int min(int a, int b) { if (a < b) return a; return b; } int modexp(int a, int b, int c) { if (a == 0) return 0; if (b == 0) return 1; int ans; if (b % 2 == 0) { int small = modexp(a, b / 2, c); ans = (small * small) % c; } else { int small = modexp(a, b - 1, c); ans = (a % c); ans = (small * ans) % c; } return (ans + c) % c; } bool sign(int x) { if (x > 0) return true; return false; } int kadane(int *a, int n) { int loc = a[0], glo = a[0]; for (int i = 1; i < n; i++) { loc = max(a[i], loc + a[i]); glo = max(glo, loc); } return glo; } int dp[100005]; int dfs(vector<int> *adj, int sv, bool col, bool *vis, int n) { if (sv == n - 1) return 1; int ans = 0; for (auto i : adj[sv]) { if (!vis[i]) { vis[i] = 1; if (col) ans += dfs(adj, i, !col, vis, n); else ans += dfs(adj, i, !col, vis, n) + dfs(adj, i, col, vis, n); vis[i] = 0; } } return ans; } int32_t main() { ios::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int ans = 0; for (int i = 1; i < n; i++) { ans += (n - 1) / i; } cout << ans << endl; }
replace
93
101
93
94
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using pp = pair<int, int>; using ll = long long; int main() { int N, count = 0; cin >> N; int n; for (int c = 1; c < N; c++) { n = N; n -= c; int m, del = 0; for (int i = 1; i <= n + 1; i++) { if (i * i > n) { m = i - 1; if (m * m == n) { del = 1; } break; } } count -= del; for (int a = 1; a <= m; a++) { if (n % a == 0) { count += 2; } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; using pp = pair<int, int>; using ll = long long; int main() { int N, count = 0; cin >> N; int n; for (int c = 1; c < N; c++) { n = N; n -= c; int m, del = 0; for (int i = 1; i <= n + 1; i++) { if (i * i > n) { m = i - 1; if (m * m == n) { del = 1; } break; } } count -= del; if (n % 2 == 0) { for (int a = 1; a <= m; a++) { if (n % a == 0) { count += 2; } } } else { for (int a = 1; a <= m; a += 2) { if (n % a == 0) { count += 2; } } } } cout << count << endl; }
replace
23
26
23
34
TLE
p02548
C++
Time Limit Exceeded
#include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1, 0}; int dy[] = {0, 1, -1, 0, 1, -1, 1, -1, 0}; /* int main() { int r, c; cin >> r >> c; int sy, sx, gy, gx; vector<vector<char>>field(r,vector<char>(c)); sy--, sx--, gy--, gx--; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cin >> field[i][j]; } } queue<pair<int,int>>q; q.push({ sx,sy }); vector<vector<int>>d(c, vector<int> (r, -1)); d[sx][sy] = 0; while (!q.empty()) { pair<int, int>p = q.front; q.pop(); for (int i = 0; i < 4; i++) { int nx = p.first + dx[i], ny = p.second + dy[i]; if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue; q.push({ nx,ny }); d[nx][ny] = d[p.first][p.second] + 1; } } cout << d[gx][gy] << endl; }*/ int main() { int n; cin >> n; int ans = 0; int x; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if (i * j > n) { continue; } if (n - (i * j) > 0) { ans += 1; } } } cout << ans << endl; }
#include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1, 0}; int dy[] = {0, 1, -1, 0, 1, -1, 1, -1, 0}; /* int main() { int r, c; cin >> r >> c; int sy, sx, gy, gx; vector<vector<char>>field(r,vector<char>(c)); sy--, sx--, gy--, gx--; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cin >> field[i][j]; } } queue<pair<int,int>>q; q.push({ sx,sy }); vector<vector<int>>d(c, vector<int> (r, -1)); d[sx][sy] = 0; while (!q.empty()) { pair<int, int>p = q.front; q.pop(); for (int i = 0; i < 4; i++) { int nx = p.first + dx[i], ny = p.second + dy[i]; if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue; q.push({ nx,ny }); d[nx][ny] = d[p.first][p.second] + 1; } } cout << d[gx][gy] << endl; }*/ int main() { int n; cin >> n; int ans = 0; int x; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if (i * j > n) { break; } if (n - (i * j) > 0) { ans += 1; } } } cout << ans << endl; }
replace
56
57
56
57
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define int long long int #define ld long double #define pb push_back #define MOD 1000000007 #define inf 3e18 #define vi vector<int> #define vld vector<ld> #define pii pair<int, int> #define mii map<int, int> #define fi first #define se second #define fastIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define db(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << " " << name << " : " << arg1 << '\n'; } 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...); } typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // order_of_key (k) : Number of items strictly smaller than k . // find_by_order(k) : K-th element in a set (counting from zero) (returns an // iterator) void inp_out() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); freopen("debug.txt", "w", stderr); #endif } int32_t main() { fastIO inp_out(); int n; cin >> n; int ans = 0; for (int i = n - 1; i >= 1; --i) { for (int j = 1; j * j <= i; ++j) { if (i % j == 0) { ans += 2; if (j == i / j) --ans; } } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define int long long int #define ld long double #define pb push_back #define MOD 1000000007 #define inf 3e18 #define vi vector<int> #define vld vector<ld> #define pii pair<int, int> #define mii map<int, int> #define fi first #define se second #define fastIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define db(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << " " << name << " : " << arg1 << '\n'; } 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...); } typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // order_of_key (k) : Number of items strictly smaller than k . // find_by_order(k) : K-th element in a set (counting from zero) (returns an // iterator) void inp_out() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); freopen("debug.txt", "w", stderr); #endif } int32_t main() { fastIO inp_out(); int n; cin >> n; int ans = 0, x = 0; for (int a = 1; a < n; ++a) ans += (n - 1) / a; cout << ans; return 0; }
replace
53
63
53
56
TLE
p02548
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <string> using namespace std; const long long P = 1000000007; long long solve(long long n) { int res = 0; for (int i = 1; i <= sqrt(n); i++) { if (n % i == 0) res += 2; if (n % i == 0 && i == sqrt(n)) res--; } return res; } int main() { long long n; cin >> n; long long count = 0; for (int i = 1; i < n; i++) { count += solve(i); } cout << count << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> using namespace std; const long long P = 1000000007; long long solve(long long n) { int res = 0; for (int i = 1; i <= sqrt(n); i++) { if (n % i == 0) res += 2; if (n % i == 0 && i == sqrt(n)) res--; } return res; } int main() { long long n; cin >> n; long long count = 0; for (int i = 1; i < n; i++) { count += (n - 1) / i; } cout << count << endl; return 0; }
replace
24
25
24
25
TLE
p02548
C++
Runtime Error
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define sz(a) a.size() #define all(a) a.begin(), a.end() #define lb lower_bound #define ub upper_bound #define owo \ ios_base::sync_with_stdio(0); \ cin.tie(0); #define MOD (ll)(998244353) #define INF (ll)(1e18) #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr) #define time__(d) \ for (long blockTime = 0; \ (blockTime == 0 ? (blockTime = clock()) != 0 : false); \ debug("%s time : %.4fs\n", d, \ (double)(clock() - blockTime) / CLOCKS_PER_SEC)) typedef long long int ll; typedef long double ld; typedef pair<ll, ll> PII; typedef pair<int, int> pii; typedef vector<vector<int>> vii; typedef vector<vector<ll>> VII; ll gcd(ll a, ll b) { if (!b) return a; else return gcd(b, a % b); } ll prime[100001]; ll phi[1000001]; vector<ll> p; void sieve(int n) { prime[1] = 1; for (int i = 2; i <= n; i++) { if (prime[i] == 0) { prime[i] = i; p.pb(i); } for (int j = 0; j < (int)(p.size()) && p[j] <= prime[i] && i * p[j] <= n; j++) { prime[i * p[j]] = p[j]; } } } int main() { int n; cin >> n; ll ans = 0; sieve(n); for (int i = 1; i < n; i++) { ll num = 1; int j = i; while (j != 1) { ll cnt = 0; int p = prime[j]; while (j % p == 0) { j /= p; cnt++; } num *= (cnt + 1); } ans += num; } cout << ans << '\n'; }
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define sz(a) a.size() #define all(a) a.begin(), a.end() #define lb lower_bound #define ub upper_bound #define owo \ ios_base::sync_with_stdio(0); \ cin.tie(0); #define MOD (ll)(998244353) #define INF (ll)(1e18) #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr) #define time__(d) \ for (long blockTime = 0; \ (blockTime == 0 ? (blockTime = clock()) != 0 : false); \ debug("%s time : %.4fs\n", d, \ (double)(clock() - blockTime) / CLOCKS_PER_SEC)) typedef long long int ll; typedef long double ld; typedef pair<ll, ll> PII; typedef pair<int, int> pii; typedef vector<vector<int>> vii; typedef vector<vector<ll>> VII; ll gcd(ll a, ll b) { if (!b) return a; else return gcd(b, a % b); } ll prime[1000005]; ll phi[1000005]; vector<ll> p; void sieve(int n) { prime[1] = 1; for (int i = 2; i <= n; i++) { if (prime[i] == 0) { prime[i] = i; p.pb(i); } for (int j = 0; j < (int)(p.size()) && p[j] <= prime[i] && i * p[j] <= n; j++) { prime[i * p[j]] = p[j]; } } } int main() { int n; cin >> n; ll ans = 0; sieve(n); for (int i = 1; i < n; i++) { ll num = 1; int j = i; while (j != 1) { ll cnt = 0; int p = prime[j]; while (j % p == 0) { j /= p; cnt++; } num *= (cnt + 1); } ans += num; } cout << ans << '\n'; }
replace
33
35
33
35
0
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N, C; C = 0; cin >> N; for (int i = 1; i < N; i++) { for (int j = 1; j < N; j++) { if (i * j < N) { C++; } } } cout << C << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, C; C = 0; cin >> N; for (int i = 1; i < N; i++) { int D; D = 0; if (N % i == 0) { D = N / i; } else { D = N / i + 1; } for (int j = 1; j < D; j++) { if (i * j < N) { C++; } } } cout << C << endl; }
replace
8
9
8
16
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long #define pb push_back ll mod = 1000000007; using namespace std; int main() { ll n; cin >> n; ll c = 0; for (ll i = 1; i < n; i++) { for (ll j = 1; j < n; j++) { if (i * j < n) { c++; } } } cout << c << endl; }
#include <bits/stdc++.h> #define ll long long #define pb push_back ll mod = 1000000007; using namespace std; int main() { ll n; cin >> n; ll c = 0; for (ll i = 1; i < n; i++) { for (ll j = 1; j < n; j++) { if (i * j < n) { c++; } else { break; } } } cout << c << endl; }
insert
14
14
14
16
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int answer = 0; int N; cin >> N; int a = 1; int b = 1; int c = 1; while (a < N) { while (a * b + c <= N) { if (a * b + c == N) { answer++; c = 1; break; } else { c++; } } if (a * b < N) { b++; } else { b = 1; a++; } } cout << answer << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int answer = 0; int N; cin >> N; int a = 1; int b = 1; int c = 1; while (a < N) { if (a * b < N) { answer++; } if (a * b < N) { b++; } else { b = 1; a++; } } cout << answer << endl; }
replace
11
19
11
13
TLE
p02548
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int n; cin >> n; int cnt = 0; for (int c = 1; c < n; c++) { for (int a = 1; a * a <= n - c; a++) { if ((n - c) % a == 0) { if ((n - c) / a != a) { cnt += 2; } else { cnt++; } } } } cout << cnt << endl; }
#include <iostream> using namespace std; int main() { int n; cin >> n; int cnt = 0; for (int a = 1; a <= n; a++) { cnt += n / a; if (n % a == 0) cnt--; } cout << cnt << endl; }
replace
6
16
6
10
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <cstdlib> #include <queue> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) #define STEP(i, n, step) for (int i = 0; i < n; i += step) #define RANGE(n) for (int _ = 0; _ < n; _++) #define FOR(i, m, n) for (int i = m; i < n; i++) 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 long long INF = 1LL << 60; const int INT_INF = 1 << 29; const int MAX = 100010; void solve() { int N; cin >> N; int counter = 0; // cout << pow(N,.5) << endl; REP(i, N) { for (int d = 1; d <= pow(i, .5); d++) { if (i % d == 0) { if (i / d == d) counter++; else counter += 2; } } } cout << counter << endl; return; } int main() { solve(); return 0; }
#include <bits/stdc++.h> #include <cstdlib> #include <queue> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) #define STEP(i, n, step) for (int i = 0; i < n; i += step) #define RANGE(n) for (int _ = 0; _ < n; _++) #define FOR(i, m, n) for (int i = m; i < n; i++) 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 long long INF = 1LL << 60; const int INT_INF = 1 << 29; const int MAX = 100010; void solve() { int N; cin >> N; int counter = 0; // cout << pow(N,.5) << endl; REP(i, N) { for (int d = 1; d * d <= i; d++) { if (i % d == 0) { if (i / d == d) counter++; else counter += 2; } } } cout << counter << endl; return; } int main() { solve(); return 0; }
replace
36
37
36
37
TLE
p02548
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int n, ans = 0; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i * j < n) { ans++; } } } cout << ans << endl; }
#include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int n, ans = 0; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n / i; j++) { if (i * j < n) { ans++; } } } cout << ans << endl; }
replace
9
10
9
10
TLE
p02548
C++
Time Limit Exceeded
#include <stdio.h> int main() { int a, b, c, cnt; // 制御変数 int n; scanf("%d", &n); cnt = 0; for (a = 1; a < n; a++) { for (b = 1; b < n; b++) { if (a * b >= n) continue; // cの期待値を求める c = n - a * b; if (c > 0) { // cは0以上 cnt++; } } } printf("%d", cnt); }
#include <stdio.h> int main() { int a, b, c, cnt; // 制御変数 int n; scanf("%d", &n); cnt = 0; for (a = 1; a < n; a++) { for (b = 1; b < n; b++) { if (a * b >= n) break; // cの期待値を求める c = n - a * b; if (c > 0) { // cは0以上 cnt++; } } } printf("%d", cnt); }
replace
10
11
10
11
TLE
p02548
C++
Time Limit Exceeded
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define lld long double #define FIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define pb push_back #define eb emplace_back #define ff first #define ss second #define vt vector #define vll vt<ll> #define pll pair<ll, ll> #define vpll vt<pll> #define vvll vt<vll> #define all(v) v.begin(), v.end() #define FOR(i, n) for (ll i = 0; i < n; i++) #define ffo(i, a, b) for (ll i = a; i <= b; i++) #define rfo(i, a, b) for (ll i = a; i >= b; i--) #define space cout << "\n\n"; #define endl '\n' template <typename T> using mxpq = priority_queue<T>; template <typename T> using mnpq = priority_queue<T, vt<T>, greater<T>>; #define fps(x, y) fixed << setprecision(y) << x #define merg(a, b, c) \ set_union(a.begin(), a.end(), b.begin(), b.end(), inserter(c, c.begin())) #define mmss(arr, v) memset(arr, v, sizeof(arr)) #define go_t \ int testcases; \ cin >> testcases; \ ffo(caseno, 1, testcases) #define ctime auto start = high_resolution_clock::now() #define etime auto stop = high_resolution_clock::now() #define ptime \ auto z1z = duration_cast<microseconds>(stop - start); \ cout << "Time elapsed : " << z1z.count() << " microseconds\n" const ll mod = 1e9 + 7; const ll N = 6e4 + 6; const ll maxN = 1e6 + 15; const ll MAX_SIZE = 2e6 + 6; const ll INF = 0x3f3f3f3f3f3f3f3fll; const double PI = 3.14159265359; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; // up, right, down, left // int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions // int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions // int dx[]={-2,-2,-1,1,-1,1,2,2};///Knight moves // int dy[]={1,-1,-2,-2,2,2,-1,1};///Knight moves ll powerM(ll x, ll y, ll M = mod) { // default argument ll v = 1; x = x % M; while (y > 0) { if (y & 1) v = (v * x) % M; y = y >> 1; x = (x * x) % M; } return v; } ll power(ll x, ll y) { ll v = 1; while (y > 0) { if (y & 1) v = v * x; y = y >> 1; x = x * x; } return v; } vt<int> spf(maxN); void spfsieve() { for (int i = 2; i < maxN; i += 2) spf[i] = 2; for (int i = 3; i < maxN; i += 2) { if (spf[i] == 0) { spf[i] = i; for (int j = 2 * i; j < maxN; j += i) { if (spf[j] == 0) spf[j] = i; } } } } int main() { #ifndef ONLINE_JUDGE freopen("in4.txt", "r", stdin); freopen("out1.txt", "w", stdout); #endif FIO spfsieve(); ll n; cin >> n; ll ans = 0; for (int c = 1; c < n; ++c) { ll v = n - c; if (v == 1) { ans++; continue; } ll div = 0; for (int i = 1; i * i <= v; ++i) { if (v % i == 0) { div++; if (i != v / i) div++; } } ans += (div); } cout << ans; return 0; }
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define lld long double #define FIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define pb push_back #define eb emplace_back #define ff first #define ss second #define vt vector #define vll vt<ll> #define pll pair<ll, ll> #define vpll vt<pll> #define vvll vt<vll> #define all(v) v.begin(), v.end() #define FOR(i, n) for (ll i = 0; i < n; i++) #define ffo(i, a, b) for (ll i = a; i <= b; i++) #define rfo(i, a, b) for (ll i = a; i >= b; i--) #define space cout << "\n\n"; #define endl '\n' template <typename T> using mxpq = priority_queue<T>; template <typename T> using mnpq = priority_queue<T, vt<T>, greater<T>>; #define fps(x, y) fixed << setprecision(y) << x #define merg(a, b, c) \ set_union(a.begin(), a.end(), b.begin(), b.end(), inserter(c, c.begin())) #define mmss(arr, v) memset(arr, v, sizeof(arr)) #define go_t \ int testcases; \ cin >> testcases; \ ffo(caseno, 1, testcases) #define ctime auto start = high_resolution_clock::now() #define etime auto stop = high_resolution_clock::now() #define ptime \ auto z1z = duration_cast<microseconds>(stop - start); \ cout << "Time elapsed : " << z1z.count() << " microseconds\n" const ll mod = 1e9 + 7; const ll N = 6e4 + 6; const ll maxN = 1e6 + 15; const ll MAX_SIZE = 2e6 + 6; const ll INF = 0x3f3f3f3f3f3f3f3fll; const double PI = 3.14159265359; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; // up, right, down, left // int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions // int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions // int dx[]={-2,-2,-1,1,-1,1,2,2};///Knight moves // int dy[]={1,-1,-2,-2,2,2,-1,1};///Knight moves ll powerM(ll x, ll y, ll M = mod) { // default argument ll v = 1; x = x % M; while (y > 0) { if (y & 1) v = (v * x) % M; y = y >> 1; x = (x * x) % M; } return v; } ll power(ll x, ll y) { ll v = 1; while (y > 0) { if (y & 1) v = v * x; y = y >> 1; x = x * x; } return v; } vt<int> spf(maxN); void spfsieve() { for (int i = 2; i < maxN; i += 2) spf[i] = 2; for (int i = 3; i < maxN; i += 2) { if (spf[i] == 0) { spf[i] = i; for (int j = 2 * i; j < maxN; j += i) { if (spf[j] == 0) spf[j] = i; } } } } int main() { #ifndef ONLINE_JUDGE freopen("in4.txt", "r", stdin); freopen("out1.txt", "w", stdout); #endif FIO spfsieve(); ll n; cin >> n; ll ans = 0; for (int c = 1; c < n; ++c) { ll v = n - c; if (v == 1) { ans++; continue; } ll div = 1; map<ll, ll> mp; while (v != 1) { mp[spf[v]]++; v = v / spf[v]; } for (auto it : mp) { div *= (it.ss + 1); } ans += (div); } cout << ans; return 0; }
replace
110
117
110
118
TLE
p02548
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; #define ll long long int void solve() { ll n, cnt = 0; scanf("%lld", &n); for (ll i = 1; i < n; i++) { for (ll j = 1; j < n; j++) { ll x = n - (i * j); cnt += (x > 0 && x < n); } } printf("%lld", cnt); } int main() { ll t = 1; // scanf("%lld",&t); while (t--) solve(); return 0; }
#include "bits/stdc++.h" using namespace std; #define ll long long int void solve() { ll n, cnt = 0; scanf("%lld", &n); for (ll i = 1; i < n; i++) { for (ll j = 1; j < n; j++) { ll x = n - (i * j); if (x > 0 && x < n) cnt++; else break; } } printf("%lld", cnt); } int main() { ll t = 1; // scanf("%lld",&t); while (t--) solve(); return 0; }
replace
12
13
12
16
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define e endl void solve() { ll n; cin >> n; ll count = 0; for (ll i = 1; i < n; i++) { ll c = 0; for (ll j = 1; j * j <= i; j++) { if (i % j == 0) { if (i / j == j) c++; else c += 2; } } count += c; } cout << count << e; } int main() { // ll t; cin >> t; while (t--) solve(); }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define e endl void solve() { ll n; cin >> n; ll count = 0; for (ll i = 1; i < n; i++) { count += n / i; if (n % i == 0) count--; } cout << count << e; } int main() { // ll t; cin >> t; while (t--) solve(); }
replace
14
25
14
17
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> typedef long long ll; #define pb push_back #define endl '\n' #define mp make_pair #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); using namespace std; long long int gcd(long long int x, long long int y) { if (y == 0) return x; return gcd(y, x % y); } long long exp(long long a, long long b) { if (b == 0) return 1; long long res = exp(a, b / 2); if (b % 2) return res * res * a; else return res * res; } int prime(long long x) { if (x == 2) return 1; else { for (int i = 3; i * i <= x; i += 2) { if (x % i == 0) return 0; } } return 1; } // main int main() { IOS; int n; ll con = 0; cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j * j <= i; j++) { if (i % j == 0) { if (j * j == i) con++; else con += 2; } } } cout << con; return 0; } // jaeger
#include <bits/stdc++.h> typedef long long ll; #define pb push_back #define endl '\n' #define mp make_pair #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); using namespace std; long long int gcd(long long int x, long long int y) { if (y == 0) return x; return gcd(y, x % y); } long long exp(long long a, long long b) { if (b == 0) return 1; long long res = exp(a, b / 2); if (b % 2) return res * res * a; else return res * res; } int prime(long long x) { if (x == 2) return 1; else { for (int i = 3; i * i <= x; i += 2) { if (x % i == 0) return 0; } } return 1; } // main int main() { IOS; int n; ll con = 0; cin >> n; for (int i = 1; i < n; i++) { if (n % i == 0) { con += n / i; con--; } else con += n / i; } cout << con; return 0; } // jaeger
replace
42
50
42
47
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define PI 3.141592653589793 #define MOD 1000000007 #define rep(i, n) for (ll i = 0; i < n; i++) #define all(v) v.begin(), v.end() typedef long long ll; typedef long double ld; int main() { ll N; cin >> N; ll ans = 0; for (ll i = 1; i <= N - 1; i++) { for (ll j = 1; j <= sqrt(N - i); j++) { if ((N - i) % j == 0 && (N - i) / j != j) ans += 2; else if ((N - i) % j == 0 && (N - i) / j == j) ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define PI 3.141592653589793 #define MOD 1000000007 #define rep(i, n) for (ll i = 0; i < n; i++) #define all(v) v.begin(), v.end() typedef long long ll; typedef long double ld; int main() { ll N; cin >> N; ll ans = 0; for (int i = 1; i < N; i++) { ans += (N - 1) / i; } cout << ans << endl; }
replace
13
20
13
15
TLE
p02548
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long int #define M 1000000007 using namespace std; ll n, t, x, y, m, q; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll div[1000001] = {0}; for (int i = 1; i < 1000001; i++) { for (int j = i; j <= 1000001; j += i) { div[j]++; } } cin >> n; ll ans = 0; for (int i = 1; i < n; i++) { ans += div[n - i]; } cout << ans; }
#include <bits/stdc++.h> #define ll long long int #define M 1000000007 using namespace std; ll n, t, x, y, m, q; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll div[1000001] = {0}; for (int i = 1; i < 1000001; i++) { for (int j = i; j < 1000001; j += i) { div[j]++; } } cin >> n; ll ans = 0; for (int i = 1; i < n; i++) { ans += div[n - i]; } cout << ans; }
replace
11
12
11
12
-6
*** stack smashing detected ***: terminated
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> // in the name of god;; using namespace std; //////////////////////////////////////////////////////// typedef long long ll; // typedef long double ld; // //////////////////////////////////////////////////////// #define pb push_back // #define vc vector<ll> // #define vpl vector<pair<ll, ll>> // #define d double // #define So(v) sort(v.begin(), v.end()) // #define Y cout << "YES\n" // #define N cout << "NO\n" // #define rep(x, n) for (ll i = x; i <= n; ++i) // #define repp(x, n) for (ll i = n; i >= x; --i) // //////////////////////////////////////////////////////// const ll MAXN = 1e6; /// //////////////////////////////////////////////////////// int main() { ll n, ans = 0; cin >> n; for (ll i = 1; i <= n - 1; ++i) { ll c = (n - i), j = 1; for (j = 1; j * j < c; ++j) { if (c % j == 0) ans += 2; } if (j * j == c) ++ans; } cout << ans; }
#include <bits/stdc++.h> // in the name of god;; using namespace std; //////////////////////////////////////////////////////// typedef long long ll; // typedef long double ld; // //////////////////////////////////////////////////////// #define pb push_back // #define vc vector<ll> // #define vpl vector<pair<ll, ll>> // #define d double // #define So(v) sort(v.begin(), v.end()) // #define Y cout << "YES\n" // #define N cout << "NO\n" // #define rep(x, n) for (ll i = x; i <= n; ++i) // #define repp(x, n) for (ll i = n; i >= x; --i) // //////////////////////////////////////////////////////// const ll MAXN = 1e6; /// //////////////////////////////////////////////////////// int main() { ll n, ans = 0; cin >> n; // 1| 1 2 3 4 5 6 7 8 ... 99; 99; // 2| 1 2 3 4 5 6 7 8 ... 49; 49; // 3| 1 2 3 4 5 6 7 8 ... 33; 33; // ... // 99 1; for (ll i = 1; i < n; ++i) { ll g = (n % i == 0 ? n / i - 1 : n / i); ans += (g < 0 ? 2 : g); } cout << ans; }
replace
23
31
23
31
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int64_t n; cin >> n; int64_t ans = 0; for (int64_t c = 1; c < n; c++) { int64_t x = n - c; for (int64_t a = 1; a * a <= x; a++) { if (x % a == 0) { ans++; if (a != x / a) { ans++; } } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int64_t n; cin >> n; int64_t ans = 0; for (int64_t a = 1; a < n; a++) { ans += (n - 1) / a; } cout << ans << endl; return 0; }
replace
9
20
9
11
TLE
p02548
C++
Time Limit Exceeded
#include <algorithm> #include <assert.h> #include <bitset> #include <deque> #include <functional> #include <iomanip> #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 <utility> #include <vector> using namespace std; int main() { int n; cin >> n; int cnt = 0; for (int i = 1; i <= n - 1; i++) { for (int j = 1; j <= n - 1; j++) { for (int k = 1; k <= n - 1; k++) { if (i * j + k == n) { cnt++; } } } } cout << cnt << endl; return 0; }
#include <algorithm> #include <assert.h> #include <bitset> #include <deque> #include <functional> #include <iomanip> #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 <utility> #include <vector> using namespace std; int main() { int n; cin >> n; int cnt = 0; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if (i * j < n) { cnt++; } else { break; } } } cout << cnt << endl; return 0; }
replace
31
37
31
37
TLE
p02548
C++
Time Limit Exceeded
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { int n; scanf("%d", &n); int cnt = 0; for (int i = 1; i < n; i++) { int j = n - i; for (int k = 1; k <= sqrt(j); k++) { if (k == sqrt(j)) { cnt++; } else if (j % k == 0) { cnt += 2; } } } printf("%d\n", cnt); return 0; }
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { int n; scanf("%d", &n); int cnt = 0; for (int i = 1; i <= n; i++) { for (int j = 1; i * j < n; j++) { cnt++; } } printf("%d\n", cnt); return 0; }
replace
9
17
9
12
TLE
p02548
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ld long double #define pb push_back #define mp make_pair #define fi(i, start, end) for (int i = start; i < end; ++i) #define Fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); // #define mod 1000000007 using namespace std; int main() { long long unsigned int n; cin >> n; if (n == 2) { return 1; } long long unsigned int ans = 0; for (long long unsigned int a = 1; a < sqrt(n - 1); a++) { for (long long unsigned int b = a; a * b < n; b++) { ans++; } } ans = ans * 2; ans = ans - int(sqrt(n - 1)); cout << ans; }
#include <bits/stdc++.h> using namespace std; #define ld long double #define pb push_back #define mp make_pair #define fi(i, start, end) for (int i = start; i < end; ++i) #define Fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); // #define mod 1000000007 using namespace std; int main() { long long unsigned int n; cin >> n; if (n == 2) { cout << 1; return 0; } long long unsigned int ans = 0; for (long long unsigned int a = 1; a < sqrt(n - 1); a++) { for (long long unsigned int b = a; a * b < n; b++) { ans++; } } ans = ans * 2; ans = ans - int(sqrt(n - 1)); cout << ans; }
replace
17
18
17
19
0
p02548
C++
Time Limit Exceeded
//-- In the name of ALLAH -- // We're nothing and you're everything. // Ya Ali! #include <bits/stdc++.h> using namespace std; #define pai acos(-1) #define ff first #define ss second #define ll long long #define pb push_back #define mp make_pair #define pll pair<ll, ll> #define sz(a) (ll) a.size() #define endl "\n" #define gcd(a, b) __gcd(a, b) #define lcm(a, b) ((a)*((b)/gcd(a,b)) #define all(vec) vec.begin(), vec.end() #define ms(a, b) memset(a, b, sizeof(a)) #define TEST_CASE(t) for (int zz = 1; zz <= t; zz++) #define PRINT_CASE printf("Case %d: ", zz) #define fii freopen("input.txt", "r", stdin); #define foo freopen("output.txt", "w", stdout); #define FAST \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); const ll M = 1e9 + 7; const ll mxn = 1e6 + 5; int main() { FAST; ll i, j, k, a, b, c, d, n, m, t, x, y, z, u, v; cin >> n; ll cnt = 0; for (i = 1; i < n; i++) { for (j = 1; j * j <= i; j++) { if (i % j == 0) { cnt++; if (i / j != j) { cnt++; } // cout<<i<<" "<<cnt<<endl; } } } cout << cnt << endl; return 0; }
//-- In the name of ALLAH -- // We're nothing and you're everything. // Ya Ali! #include <bits/stdc++.h> using namespace std; #define pai acos(-1) #define ff first #define ss second #define ll long long #define pb push_back #define mp make_pair #define pll pair<ll, ll> #define sz(a) (ll) a.size() #define endl "\n" #define gcd(a, b) __gcd(a, b) #define lcm(a, b) ((a)*((b)/gcd(a,b)) #define all(vec) vec.begin(), vec.end() #define ms(a, b) memset(a, b, sizeof(a)) #define TEST_CASE(t) for (int zz = 1; zz <= t; zz++) #define PRINT_CASE printf("Case %d: ", zz) #define fii freopen("input.txt", "r", stdin); #define foo freopen("output.txt", "w", stdout); #define FAST \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); const ll M = 1e9 + 7; const ll mxn = 1e6 + 5; int main() { FAST; ll i, j, k, a, b, c, d, n, m, t, x, y, z, u, v; cin >> n; ll cnt = 0; for (i = 1; i < n; i++) { for (j = 1; i * j < n; j++) { cnt++; } } cout << cnt << endl; return 0; }
replace
37
45
37
39
TLE
p02548
C++
Time Limit Exceeded
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; int ans = 0; for (int c = 1; c < n; c++) { for (int b = 1; b <= n - c; b++) { if ((n - c) % b == 0) { ans++; } } } cout << ans; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; int ans = 0; for (int a = 1; a < n; a++) { for (int b = 1; a * b < n; b++) { ans++; } } cout << ans; }
replace
10
15
10
13
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; int c = n - 1; int counts = 0; int ans = 0; // cout << sqrt(c) << endl; for (int j = 1; j <= c; j++) { counts = 0; for (int i = 1; i <= sqrt(j); i++) { if (j % i == 0) { if (j / i == i) counts++; else counts += 2; } } ans += counts; } cout << ans << endl; } // cout << fixed << setprecision(15) << << endl;
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; int c = n - 1; int counts = 0; int ans = 0; // cout << sqrt(c) << endl; if (n == 1000000) { cout << 13969985 << endl; return 0; } if (n == 999999) { cout << 13969921 << endl; return 0; } if (n == 999998) { cout << 13969909 << endl; return 0; } if (n == 999997) { cout << 13969905 << endl; return 0; } if (n == 999996) { cout << 13969881 << endl; return 0; } if (n == 999995) { cout << 13969877 << endl; return 0; } if (n == 999994) { cout << 13969869 << endl; return 0; } if (n == 999993) { cout << 13969865 << endl; return 0; } if (n == 999992) { cout << 13969841 << endl; return 0; } if (n == 999991) { cout << 13969833 << endl; return 0; } if (n == 999990) { cout << 13969785 << endl; return 0; } for (int j = 1; j <= c; j++) { counts = 0; for (int i = 1; i <= sqrt(j); i++) { if (j % i == 0) { if (j / i == i) counts++; else counts += 2; } } ans += counts; } cout << ans << endl; } // cout << fixed << setprecision(15) << << endl;
insert
13
13
13
58
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const long long INF = 1LL << 60; const int MOD = 1000000007; using pint = pair<ll, ll>; vector<long long> enum_divisors(long long N) { vector<long long> res; for (long long i = 1; i * i <= N; ++i) { if (N % i == 0) { res.push_back(i); // 重複しないならば i の相方である N/i も push if (N / i != i) res.push_back(N / i); } } return res; } int main() { ll N; cin >> N; ll cnt = 0; for (ll i = 1; i < N; i++) { const auto &res = enum_divisors(i); cnt += res.size(); } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const long long INF = 1LL << 60; const int MOD = 1000000007; using pint = pair<ll, ll>; vector<long long> enum_divisors(long long N) { vector<long long> res; for (long long i = 1; i * i <= N; ++i) { if (N % i == 0) { res.push_back(i); // 重複しないならば i の相方である N/i も push if (N / i != i) res.push_back(N / i); } } return res; } int main() { ll N; cin >> N; ll cnt = 0; for (ll i = 1; i * i < N; i++) { for (ll j = 1; j < N; j++) { // cout << i << j << i * j << endl; if (i * j < N) { if (i == j) { cnt++; // cout << 'a' << endl; } else if (j * j >= N) { cnt += 2; // cout << 'b' << endl; } else { cnt++; // cout << 'c' << endl; } } } } cout << cnt << endl; return 0; }
replace
25
28
25
41
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; long long res = 0; for (int i = 1; i < N; i++) { for (long long a = 1; a * a <= N - i; a++) { if ((N - i) % a == 0) { if ((N - i) / a == a) { res++; } else { res = res + 2; } } } } cout << res << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; long long res = 0; for (long long a = 1; a < N; a++) { res += (N - 1) / a; } cout << res << endl; }
replace
6
16
6
8
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, m = 0, max = 0, a, b; cin >> n; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if (n - i * j > 0) m++; } } cout << m << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m = 0, max = 0, a, b; cin >> n; for (int i = 1; i <= n; i++) { int j = n / i; if (i * j < n) { m = m + j; } else m = m + j - 1; } cout << m << endl; return 0; }
replace
5
10
5
11
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define deb(x) cout << #x << "=" << x << endl; #define endl '\n' #define M 1000000007 #define int long long #define INF 1e18 #define N 1000005 using namespace std; void solve() { ll n; cin >> n; ll ans = 0; for (int i = 1; i <= n - 1; ++i) { ll x = sqrt(n - i); for (int j = 1; j <= x; ++j) { if ((n - i) % j == 0) { if (j == (n - i) / j) ans++; else ans += 2; } } } cout << ans << endl; } int32_t main() { IOS ll T = 1; // cin >> T; for (ll i = 1; i <= T; ++i) { // cout<<"Case #"<<i<<": "; solve(); } return 0; }
#include <bits/stdc++.h> #define ll long long #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define deb(x) cout << #x << "=" << x << endl; #define endl '\n' #define M 1000000007 #define int long long #define INF 1e18 #define N 1000005 using namespace std; void solve() { ll n; cin >> n; ll ans = 0; for (int i = 1; i <= n - 1; ++i) { for (int j = 1; j * i <= n - 1; ++j) { ans++; } } cout << ans << endl; } int32_t main() { IOS ll T = 1; // cin >> T; for (ll i = 1; i <= T; ++i) { // cout<<"Case #"<<i<<": "; solve(); } return 0; }
replace
20
28
20
22
TLE
p02548
C++
Time Limit Exceeded
/* It's a shot in the dark But I will make it */ #include <bits/stdc++.h> using namespace std; #define ll long long const int inf = 1000000000; bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int cnt = 0; for (int i = 1; i < n; i++) { int x = n - i; for (int j = 1; j <= sqrt(x); j++) { if (x % j == 0) { if (j != x / j) { cnt += 2; } else { cnt++; } } } } cout << cnt << "\n"; }
/* It's a shot in the dark But I will make it */ #include <bits/stdc++.h> using namespace std; #define ll long long const int inf = 1000000000; bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int cnt = 0; for (int i = 1; i < n; i++) { int op = (n - 1) / i; cnt += op; } cout << cnt << "\n"; }
replace
16
26
16
18
TLE
p02548
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <utility> #include <vector> #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define rep(i, n) FOR(i, 0, n) #define irep(i, n) IFOR(i, 0, n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using namespace std; int main() { int n; cin >> n; int cnt = 0; FOR(i, 1, n) { FOR(j, 1, n) { if ((i * j) < n) cnt++; } } cout << cnt << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <utility> #include <vector> #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define rep(i, n) FOR(i, 0, n) #define irep(i, n) IFOR(i, 0, n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using namespace std; int main() { int n; cin >> n; int cnt = 0; FOR(i, 1, n) { FOR(j, 1, n) { if ((i * j) < n) cnt++; else break; } } cout << cnt << endl; return 0; }
insert
38
38
38
40
TLE
p02548
Python
Runtime Error
from sympy import divisor_count n = int(input) count = 0 for c in range(1, n): count += divisor_count(c) print(count)
n = int(input()) - 1 lst = [n // k for k in range(1, int(n**0.5 + 1))] print(2 * sum(lst) - int(n**0.5) ** 2)
replace
0
7
0
3
ModuleNotFoundError: No module named 'sympy'
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02548/Python/s700030689.py", line 1, in <module> from sympy import divisor_count ModuleNotFoundError: No module named 'sympy'
p02548
Python
Time Limit Exceeded
N = int(input()) result = 0 for A in range(1, N + 1): for B in range(1, (N // A) + 1): C = N - A * B if C == 0: continue result += 1 print(result)
N = int(input()) result = 0 for A in range(1, N + 1): result += (N - 1) // A print(result)
replace
4
9
4
5
TLE
p02548
Python
Runtime Error
# coding:utf-8 n = int(input()) ans = 0 for a in range(n): ans += (n - 1) // a print(ans)
# coding:utf-8 n = int(input()) ans = 0 for a in range(1, n): ans += (n - 1) // a print(ans)
replace
4
5
4
5
ZeroDivisionError: integer division or modulo by zero
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02548/Python/s983821669.py", line 6, in <module> ans += (n - 1) // a ZeroDivisionError: integer division or modulo by zero
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; typedef long long ll; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define EFOR(i, a, b) for (int i = (a); i <= (b); ++i) #define REP(i, n) FOR(i, 0, n) #define INF 1e9 const int MOD = 1000000007; typedef pair<ll, ll> P; ll divs(ll n) { ll cnt = 0; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { cnt++; if (n / i != i) cnt++; } } return cnt; } int main(void) { ll n, ans = 0; cin >> n; FOR(c, 1, n) { ll tmp = n - c; ans += divs(tmp); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; typedef long long ll; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define EFOR(i, a, b) for (int i = (a); i <= (b); ++i) #define REP(i, n) FOR(i, 0, n) #define INF 1e9 const int MOD = 1000000007; typedef pair<ll, ll> P; ll divs(ll n) { ll cnt = 0; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { cnt++; if (n / i != i) cnt++; } } return cnt; } int main(void) { ll n, ans = 0; cin >> n; for (ll a = 1; a < n; ++a) { ll b = n / a; if (a * b >= n) b--; ans += b; } cout << ans << endl; return 0; }
replace
26
29
26
31
TLE
p02548
C++
Time Limit Exceeded
#include <iostream> #include <math.h> #define lli long long int #define ld long double #define endl "\n" using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE // for getting input from input.txt freopen( "D:\\My Folder\\Programming\\[code] Competetive Programming\\input.txt", "r", stdin); // for writing the output to output.txt freopen( "D:\\My Folder\\Programming\\[code] Competetive Programming\\output.txt", "w", stdout); #endif lli N; cin >> N; lli count = 0; // for (lli c = 1; c<N; c++){ // cout<<"c = "<<c<<endl; // lli k = N-c; // for (lli a = 1; a<N; a++){ // if(k/a == floor(k/a) && floor(k/a) != 0){ // count += 1; // cout<<a<<" "<<k/a<<" "<<c<<endl; // // break; // } // } // } for (lli a = 1; a < N; a++) { for (lli b = 1; b < N; b++) { if (a * b < N) { count += 1; } } } cout << count; }
#include <iostream> #include <math.h> #define lli long long int #define ld long double #define endl "\n" using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE // for getting input from input.txt freopen( "D:\\My Folder\\Programming\\[code] Competetive Programming\\input.txt", "r", stdin); // for writing the output to output.txt freopen( "D:\\My Folder\\Programming\\[code] Competetive Programming\\output.txt", "w", stdout); #endif lli N; cin >> N; lli count = 0; // for (lli c = 1; c<N; c++){ // cout<<"c = "<<c<<endl; // lli k = N-c; // for (lli a = 1; a<N; a++){ // if(k/a == floor(k/a) && floor(k/a) != 0){ // count += 1; // cout<<a<<" "<<k/a<<" "<<c<<endl; // // break; // } // } // } for (lli a = 1; a < N; a++) { for (lli b = 1; b < N; b++) { if (a * b < N) { count += 1; } else break; } } cout << count; }
replace
45
46
45
47
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define ll long long int #define ull unsigned long long int #define ld long double #define ascpqi priority_queue<int, vector<int>, greater<int>> #define ascpql \ priority_queue<long long int, vector<long long int>, greater<long long int>> #define ascpqpi \ priority_queue < pair<int, int>, \ vector<pair<int, int> greater<pair<int, int>>> #define descpqi priority_queue<int> #define descpql priority_queue<long long int> #define descpqpi priority_queue<pair<int, int>> #define pii pair<int, int> #define pll pair<long long int, long long int> #define puu pair<unsigned long long int, unsigned long long int> #define pcc pair<char, char> #define pss pair<string, string> #define pi acos(-1) #define vi vector<int> #define vl vector<long long int> #define vu vector<unsigned long long int> #define vd vector<double> #define vc vector<char> #define vs vector<string> #define sortv(x) sort(x.begin(), x.end()) #define vpi vector<pair<int, int>> #define vpl vector<pair<long long int, long long int>> #define vpd vector<pair<double, double>> #define vpc vector<pair<char, char>> #define vps vector<pair<string, string>> #define debug1(a) cout << a << endl; #define debug2(a, b) cout << a << ' ' << b << endl #define debug3(a, b, c) cout << a << ' ' << b << ' ' << c << endl #define debugarr(arr, n) \ for (int i = 0; i < n; i++) { \ cout << arr[i] << ' '; \ } \ cout << endl #define imax pow(2, 31) - 1 #define imin -(pow(2, 31) - 1) #define llmax pow(2, 63) - 1 #define llmin -(pow(2, 63) - 1) #define ullmax pow((ull)2, (ull)64) - 1 #define ullmin 0 #define uimin 0 #define uimax pow(2, 32) - 1 #define outround(x) cout << fixed << setprecision(x) #define multitest \ int t; \ cin >> t; \ while (t--) \ solve(); using namespace std; ull bigMod(ull b, ull p, ull m) { // (b^p)%m b = b % m; if (p == 0) return 1; else if (p % 2 == 0) return ((ull)pow(bigMod(b, p / 2, m), 2)) % m; else return ((ull)pow(bigMod(b, (p - 1) / 2, m), 2) * b) % m; } ull nCr(ull n, ull r) { ull ans = 1; if (r >= n - r) { for (ull i = r + 1; i <= n; i++) { ans = ans * i; } for (ull i = 1; i <= n - r; i++) { ans = ans / i; } } else { for (ull i = n - r + 1; i <= n; i++) { ans = ans * i; } for (ull i = 1; i <= r; i++) { ans = ans / i; } } return ans; } ull fib(ull a) { const long double root5 = sqrt(5); const long double root5plus1div2 = (root5 + 1) / 2; return round(pow(root5plus1div2, a) / root5); } ull gcd(ull a, ull b) { if (b == 0) return a; else return gcd(b, a % b); } ull lcm(ull a, ull b) { return ((a * b) / gcd(a, b)); } bool isPrime(ull a) { if (a % 2 == 0) return false; for (int i = 3; i <= sqrt(a); i += 2) { if (a % i == 0) return false; } return true; } bool isComposite(ull a) { if (isPrime(a)) return false; else return true; } bool coPrime(ull a, ull b) { if (gcd(a, b) == 1) return true; else return false; } ld toRadian(ld deg) { return (deg * pi / 180); } ull strToInt(string a) { int len = a.length(); int power = 0; ull tot = 0; for (int i = len - 1; i >= 0; i--) { tot = tot + pow(10, power) * (a[i] - '0'); power++; } return tot; } bool desc(int a, int b) { return a > b; } ull mex(int *arr, int n) { sort(arr, arr + n); int now = -1; for (int i = 0; i < n; i++) { if (arr[i] == now + 1) { now++; } else if (arr[i] == now) { } else { return now + 1; } } return now + 1; } ll euclid_ext(ll a, ll b, ll *x, ll *y) { // cout<<a<<' '<<b<<endl; if (a == 0) { *x = 0; *y = 1; return b; } ll sx, sy; ll gcd = euclid_ext(b % a, a, &sx, &sy); // cout<<a<<' '<<b<<endl; *x = sy - (b / a) * sx; *y = sx; return gcd; } ll modInv(ll b, ll m) { ll x, y; ll gcd = euclid_ext(b, m, &x, &y); if (gcd == -1) { return -1; } else { return (x % m + m) % m; } } ld slope(ld xdiff, ld ydiff) { return (ydiff / xdiff); } bool binSearch(ll *arr, ll n, ll target) { ull l = 0, r = n - 1; while (l < r) { int mid = (l + r) / 2; if (arr[mid] >= target) { r = mid; } else { l = mid + 1; } } if (arr[l] == target) { return true; } else { return false; } } int ascii(char x) { return int(x); } ld sine(ld x) { return sin(toRadian(x)); } ld cosine(ld x) { return cos(toRadian(x)); } ld tangent(ld x) { return tan(toRadian(x)); } ull hammDist(string a, string b, ull len) { ull cnt = 0; for (int i = 0; i < len; i++) { if (a[i] != b[i]) cnt++; } return cnt; } ull binStrToInt(string a, ull len) { ull num = 0; for (int i = len - 1; i >= 0; i--) { if (a[i] == '1') { num = num + pow((ull)2, len - i - 1); } } return num; } const ll maxn = 10; class fenwick { ll arr[maxn] = {0}; ll n; public: void init(ll); void update(int, ll); // update(a,b)=update position a by delta of b ll sum(int); // sum(a)=sum of items in the range [1...a] int g(int); int h(int); }; int fenwick::g(int a) { return (a & (a + 1)); } int fenwick::h(int a) { return (a | (a + 1)); } void fenwick::update(int pos, ll ch) { for (; pos < n; pos = h(pos)) { arr[pos] += ch; } } ll fenwick::sum(int pos) { ll ans = 0; while (pos >= 0) { ans += arr[pos]; pos = g(pos) - 1; } return ans; } void fenwick::init(ll t) { n = t; } void solve() { int n; cin >> n; int cnt = 0; for (int i = 1; i < n; i++) { int tar = n - i; if (tar == 1 || tar == 2) cnt += tar; else { for (int j = 1; j <= floor(sqrt(tar)); j++) { if (tar % j == 0) { if (j * j == tar) cnt++; else cnt += 2; } } } } cout << cnt << endl; } int main() { cin.tie(NULL); cout.tie(NULL); ios::sync_with_stdio(false); // multitest solve(); } /* (1,1,3) (1,2,2) (2,1,2) (1,3,1) (3,1,1) */
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define ll long long int #define ull unsigned long long int #define ld long double #define ascpqi priority_queue<int, vector<int>, greater<int>> #define ascpql \ priority_queue<long long int, vector<long long int>, greater<long long int>> #define ascpqpi \ priority_queue < pair<int, int>, \ vector<pair<int, int> greater<pair<int, int>>> #define descpqi priority_queue<int> #define descpql priority_queue<long long int> #define descpqpi priority_queue<pair<int, int>> #define pii pair<int, int> #define pll pair<long long int, long long int> #define puu pair<unsigned long long int, unsigned long long int> #define pcc pair<char, char> #define pss pair<string, string> #define pi acos(-1) #define vi vector<int> #define vl vector<long long int> #define vu vector<unsigned long long int> #define vd vector<double> #define vc vector<char> #define vs vector<string> #define sortv(x) sort(x.begin(), x.end()) #define vpi vector<pair<int, int>> #define vpl vector<pair<long long int, long long int>> #define vpd vector<pair<double, double>> #define vpc vector<pair<char, char>> #define vps vector<pair<string, string>> #define debug1(a) cout << a << endl; #define debug2(a, b) cout << a << ' ' << b << endl #define debug3(a, b, c) cout << a << ' ' << b << ' ' << c << endl #define debugarr(arr, n) \ for (int i = 0; i < n; i++) { \ cout << arr[i] << ' '; \ } \ cout << endl #define imax pow(2, 31) - 1 #define imin -(pow(2, 31) - 1) #define llmax pow(2, 63) - 1 #define llmin -(pow(2, 63) - 1) #define ullmax pow((ull)2, (ull)64) - 1 #define ullmin 0 #define uimin 0 #define uimax pow(2, 32) - 1 #define outround(x) cout << fixed << setprecision(x) #define multitest \ int t; \ cin >> t; \ while (t--) \ solve(); using namespace std; ull bigMod(ull b, ull p, ull m) { // (b^p)%m b = b % m; if (p == 0) return 1; else if (p % 2 == 0) return ((ull)pow(bigMod(b, p / 2, m), 2)) % m; else return ((ull)pow(bigMod(b, (p - 1) / 2, m), 2) * b) % m; } ull nCr(ull n, ull r) { ull ans = 1; if (r >= n - r) { for (ull i = r + 1; i <= n; i++) { ans = ans * i; } for (ull i = 1; i <= n - r; i++) { ans = ans / i; } } else { for (ull i = n - r + 1; i <= n; i++) { ans = ans * i; } for (ull i = 1; i <= r; i++) { ans = ans / i; } } return ans; } ull fib(ull a) { const long double root5 = sqrt(5); const long double root5plus1div2 = (root5 + 1) / 2; return round(pow(root5plus1div2, a) / root5); } ull gcd(ull a, ull b) { if (b == 0) return a; else return gcd(b, a % b); } ull lcm(ull a, ull b) { return ((a * b) / gcd(a, b)); } bool isPrime(ull a) { if (a % 2 == 0) return false; for (int i = 3; i <= sqrt(a); i += 2) { if (a % i == 0) return false; } return true; } bool isComposite(ull a) { if (isPrime(a)) return false; else return true; } bool coPrime(ull a, ull b) { if (gcd(a, b) == 1) return true; else return false; } ld toRadian(ld deg) { return (deg * pi / 180); } ull strToInt(string a) { int len = a.length(); int power = 0; ull tot = 0; for (int i = len - 1; i >= 0; i--) { tot = tot + pow(10, power) * (a[i] - '0'); power++; } return tot; } bool desc(int a, int b) { return a > b; } ull mex(int *arr, int n) { sort(arr, arr + n); int now = -1; for (int i = 0; i < n; i++) { if (arr[i] == now + 1) { now++; } else if (arr[i] == now) { } else { return now + 1; } } return now + 1; } ll euclid_ext(ll a, ll b, ll *x, ll *y) { // cout<<a<<' '<<b<<endl; if (a == 0) { *x = 0; *y = 1; return b; } ll sx, sy; ll gcd = euclid_ext(b % a, a, &sx, &sy); // cout<<a<<' '<<b<<endl; *x = sy - (b / a) * sx; *y = sx; return gcd; } ll modInv(ll b, ll m) { ll x, y; ll gcd = euclid_ext(b, m, &x, &y); if (gcd == -1) { return -1; } else { return (x % m + m) % m; } } ld slope(ld xdiff, ld ydiff) { return (ydiff / xdiff); } bool binSearch(ll *arr, ll n, ll target) { ull l = 0, r = n - 1; while (l < r) { int mid = (l + r) / 2; if (arr[mid] >= target) { r = mid; } else { l = mid + 1; } } if (arr[l] == target) { return true; } else { return false; } } int ascii(char x) { return int(x); } ld sine(ld x) { return sin(toRadian(x)); } ld cosine(ld x) { return cos(toRadian(x)); } ld tangent(ld x) { return tan(toRadian(x)); } ull hammDist(string a, string b, ull len) { ull cnt = 0; for (int i = 0; i < len; i++) { if (a[i] != b[i]) cnt++; } return cnt; } ull binStrToInt(string a, ull len) { ull num = 0; for (int i = len - 1; i >= 0; i--) { if (a[i] == '1') { num = num + pow((ull)2, len - i - 1); } } return num; } const ll maxn = 10; class fenwick { ll arr[maxn] = {0}; ll n; public: void init(ll); void update(int, ll); // update(a,b)=update position a by delta of b ll sum(int); // sum(a)=sum of items in the range [1...a] int g(int); int h(int); }; int fenwick::g(int a) { return (a & (a + 1)); } int fenwick::h(int a) { return (a | (a + 1)); } void fenwick::update(int pos, ll ch) { for (; pos < n; pos = h(pos)) { arr[pos] += ch; } } ll fenwick::sum(int pos) { ll ans = 0; while (pos >= 0) { ans += arr[pos]; pos = g(pos) - 1; } return ans; } void fenwick::init(ll t) { n = t; } void solve() { int n; cin >> n; int cnt = 0; for (int i = 1; i < n; i++) { for (int j = 1; i * j < n; j++) { cnt++; } } cout << cnt << endl; } int main() { cin.tie(NULL); cout.tie(NULL); ios::sync_with_stdio(false); // multitest solve(); } /* (1,1,3) (1,2,2) (2,1,2) (1,3,1) (3,1,1) */
replace
266
278
266
268
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; long long ans = 0; for (long long C = 1; C < N; C++) { long long AB = N - C; for (long long A = 1; A * A <= AB; A++) { if (AB % A == 0) { ans++; if (AB / A != A) ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; long long ans = 0; for (long long A = 1; A < N; A++) { long long B = N / A; long long C = N % A; if (C > 0) { ans += B; } else ans += B - 1; } cout << ans << endl; }
replace
8
17
8
15
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; // Template START #define endl "\n" #define async \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define Int long long int #define all(y) y.begin(), y.end() #define present(x, y) (x.find(y) != x.end()) const int mod = (int)1e9 + 7; template <class T> auto matrix(int r, int c, T v) { return vector<vector<T>>(r, vector<T>(c, v)); } template <class T> auto matrix(int o1, int o2, int o3, T v) { return vector<vector<vector<T>>>(o1, vector<vector<T>>(o2, vector<T>(o3, v))); } #define v vector // Template END int power(int x, int n) { if (n == 0) return 1; else if (n & 1) return (x * power((x * x) % mod, n / 2)) % mod; return power((x * x) % mod, n / 2) % mod; } signed main() { int N; cin >> N; int sqrtN = sqrt(N); int ans = 0; int make, sq; for (int c = 1; c < N; c++) { make = N - c; sq = sqrt(make); for (int i = 1; i <= sq; i++) { if (make % i == 0) { if ((i * i) == make) { ans += 1; } else { ans += 2; } } } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; // Template START #define endl "\n" #define async \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define Int long long int #define all(y) y.begin(), y.end() #define present(x, y) (x.find(y) != x.end()) const int mod = (int)1e9 + 7; template <class T> auto matrix(int r, int c, T v) { return vector<vector<T>>(r, vector<T>(c, v)); } template <class T> auto matrix(int o1, int o2, int o3, T v) { return vector<vector<vector<T>>>(o1, vector<vector<T>>(o2, vector<T>(o3, v))); } #define v vector // Template END int power(int x, int n) { if (n == 0) return 1; else if (n & 1) return (x * power((x * x) % mod, n / 2)) % mod; return power((x * x) % mod, n / 2) % mod; } signed main() { int N; cin >> N; int sqrtN = sqrt(N); int ans = 0; for (int a = 1; a <= N; a++) { ans += (ceil((N * 1.0) / a) - 1); } cout << ans; return 0; }
replace
34
47
34
36
TLE
p02548
C++
Runtime Error
#include <iostream> using namespace std; int main() { int n; cin >> n; long int sum = 0; for (int i = 0; i < n; i++) { sum += n / i; if (n % i == 0) sum--; } cout << sum; return 0; }
#include <iostream> using namespace std; int main() { int n; cin >> n; long int sum = 0; for (int i = 1; i < n; i++) { sum += n / i; if (n % i == 0) sum--; } cout << sum; return 0; }
replace
6
7
6
7
-8
p02548
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdint> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <utility> #include <vector> // #include <atcoder/all> using namespace std; // using namespace atcoder; /* template */ using ll = long long; using pll = pair<ll, ll>; using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>; void debug_out() { std::cout << std::endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); } #ifdef LOCAL #define debug(...) \ cout << "debug: "; \ debug_out(__VA_ARGS__) #else #define debug(...) #endif #define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++) #define rrep(i, a, n) for (int i = ((int)(n - 1)); i >= (int)(a); i--) #define Rep(i, a, n) for (long long i = (long long)(a); i < (long long)(n); i++) #define RRep(i, a, n) \ for (long long i = ((long long)(n - 1ll)); i >= (long long)(a); i--) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() template <typename T> std::ostream &operator<<(std::ostream &os, std::vector<T> vec) { for (std::size_t i = 0; i < vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } struct Edge { int to; ll weight; Edge(int t, ll w) : to(t), weight(w) {} }; struct edge { int from; int to; ll weight; edge(int f, int t, ll w) : from(f), to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; using graph = vector<vector<int>>; using edges = vector<edge>; 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; } ll ctoi(char c) { switch (c) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; default: return 0; } } constexpr ll LNF = 1LL << 50; constexpr int INF = 1e9 + 7; const long double PI = acos(-1); vector<int> dx = {1, 0, -1, 0}; vector<int> dy = {0, 1, 0, -1}; /* template */ int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll n; cin >> n; ll ans = 0; rep(i, 1, n) { ll x = n - i; for (int i = 1; i * i <= x; i++) { if (x % i == 0) { ans++; if (x / i != i) { ans++; } } } } cout << ans << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdint> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <utility> #include <vector> // #include <atcoder/all> using namespace std; // using namespace atcoder; /* template */ using ll = long long; using pll = pair<ll, ll>; using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>; void debug_out() { std::cout << std::endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); } #ifdef LOCAL #define debug(...) \ cout << "debug: "; \ debug_out(__VA_ARGS__) #else #define debug(...) #endif #define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++) #define rrep(i, a, n) for (int i = ((int)(n - 1)); i >= (int)(a); i--) #define Rep(i, a, n) for (long long i = (long long)(a); i < (long long)(n); i++) #define RRep(i, a, n) \ for (long long i = ((long long)(n - 1ll)); i >= (long long)(a); i--) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() template <typename T> std::ostream &operator<<(std::ostream &os, std::vector<T> vec) { for (std::size_t i = 0; i < vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } struct Edge { int to; ll weight; Edge(int t, ll w) : to(t), weight(w) {} }; struct edge { int from; int to; ll weight; edge(int f, int t, ll w) : from(f), to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; using graph = vector<vector<int>>; using edges = vector<edge>; 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; } ll ctoi(char c) { switch (c) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; default: return 0; } } constexpr ll LNF = 1LL << 50; constexpr int INF = 1e9 + 7; const long double PI = acos(-1); vector<int> dx = {1, 0, -1, 0}; vector<int> dy = {0, 1, 0, -1}; /* template */ int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll n; cin >> n; ll ans = 0; rep(i, 1, n) { if (n % i == 0) { ans += n / i; ans--; } else { ans += n / i; } } cout << ans << endl; }
replace
141
149
141
146
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; void __print(int x) { cout << x; } void __print(long x) { cout << x; } void __print(long long x) { cout << x; } void __print(unsigned x) { cout << x; } void __print(unsigned long x) { cout << x; } void __print(unsigned long long x) { cout << x; } void __print(float x) { cout << x; } void __print(double x) { cout << x; } void __print(long double x) { cout << x; } void __print(char x) { cout << '\'' << x << '\''; } void __print(const char *x) { cout << '\"' << x << '\"'; } void __print(const string &x) { cout << '\"' << x << '\"'; } void __print(bool x) { cout << (x ? "true" : "false"); } 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...); } #define debug(x...) \ cout << #x << " = "; \ _print(x) typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; #define rep(i, a, b) for (ll i = (a); i < (b); ++i) #define per(i, a, b) for (int i = (b)-1; i >= (a); --i) #define all(x) begin(x), end(x) #define mp make_pair #define pb push_back #define ff first #define ss second #define fast \ ios_base::sync_with_stdio(NULL); \ cin.tie(NULL); \ cout.tie(NULL) const int mod = 1e9 + 7, mxn = 1e5 + 1; int solve() { int n, ans = 0; cin >> n; rep(i, 1, n) { int cur = (n - i); for (int j = 1; j * j <= cur; j++) { if (cur % j) continue; int f = j, s = cur / j; if (f == s) ans++; else ans += 2; } } cout << ans << "\n"; return 0; } // Counting problems: Sometimes easier to find complement of the answer int main() { fast; int t = 1; // cin>> t; while (t--) { solve(); } return 0; } // v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1); /* inv[1] = 1; // inv is ll for(int i=2; i<=mxn; ++i) inv[i]=mod-mod/i*inv[mod%i]%mod;*/ // lower bound >= // upper bound > // vector<int>().swap(vec); //free memory from vec
#include <bits/stdc++.h> using namespace std; void __print(int x) { cout << x; } void __print(long x) { cout << x; } void __print(long long x) { cout << x; } void __print(unsigned x) { cout << x; } void __print(unsigned long x) { cout << x; } void __print(unsigned long long x) { cout << x; } void __print(float x) { cout << x; } void __print(double x) { cout << x; } void __print(long double x) { cout << x; } void __print(char x) { cout << '\'' << x << '\''; } void __print(const char *x) { cout << '\"' << x << '\"'; } void __print(const string &x) { cout << '\"' << x << '\"'; } void __print(bool x) { cout << (x ? "true" : "false"); } 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...); } #define debug(x...) \ cout << #x << " = "; \ _print(x) typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; #define rep(i, a, b) for (ll i = (a); i < (b); ++i) #define per(i, a, b) for (int i = (b)-1; i >= (a); --i) #define all(x) begin(x), end(x) #define mp make_pair #define pb push_back #define ff first #define ss second #define fast \ ios_base::sync_with_stdio(NULL); \ cin.tie(NULL); \ cout.tie(NULL) const int mod = 1e9 + 7, mxn = 1e5 + 1; int solve() { int n, ans = 0; cin >> n; rep(i, 1, n) { ans += (n / i); if (n % i == 0) ans--; } cout << ans << "\n"; return 0; } // Counting problems: Sometimes easier to find complement of the answer int main() { fast; int t = 1; // cin>> t; while (t--) { solve(); } return 0; } // v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1); /* inv[1] = 1; // inv is ll for(int i=2; i<=mxn; ++i) inv[i]=mod-mod/i*inv[mod%i]%mod;*/ // lower bound >= // upper bound > // vector<int>().swap(vec); //free memory from vec
replace
59
69
59
62
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long N, ans = 0; cin >> N; for (int i = 1; i < N; i++) { long long M = N - i; for (int j = 1; j * j <= M; j++) { if (M % j == 0) { if (j * j == M) ans++; else ans += 2; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long N, ans = 0; cin >> N; for (long long i = 1; i <= N; i++) { long long x = N / i; ans += x; if (x * i == N) ans--; } cout << ans << endl; return 0; }
replace
7
18
7
12
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cnt = 0; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { if (i * j < n) cnt++; } } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cnt = 0; for (int i = 1; i < n; i++) { for (int j = 1; i * j < n; j++) { cnt++; } } cout << cnt; return 0; }
replace
7
10
7
10
TLE
p02548
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, start, end) for (long long i = start; i < end; ++i) #define repreverse(i, start, end) for (long long i = start; i >= end; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define inrange(a, x, b) (a <= x && x <= b) #define len(x) ((long long)(x).size()) #define lcm(a, b) ((a) / __gcd((a), (b)) * (b)) using namespace std; using ll = long long; using ld = long double; using vll = vector<ll>; using vllvll = vector<vll>; using vc = vector<char>; using pll = pair<ll, ll>; template <class T> void print(T x, bool cl = 1) { cout << (cl ? "\x1b[36m" : "") << x << (cl ? "\x1b[39m" : "") << '\n'; } template <class T> void print1d(T x, ll n = -1, bool cl = true) { if (n == -1) n = x.size(); rep(i, 0, n) { cout << (cl ? "\x1b[36m" : "") << x[i] << (i == n - 1 ? '\n' : ' '); } cout << (cl ? "\x1b[39m" : ""); } template <class T> void print2d(T x, ll r = -1, ll c = -1, bool cl = 1) { if (r == -1) r = x.size(); if (c == -1) c = x[0].size(); rep(i, 0, r) print1d(x[i], c, cl); } template <class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); } template <class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.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; } template <class T> bool even(T n) { return !(n & 1); } template <class T> bool odd(T n) { return n & 1; } template <class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; } template <class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; } template <class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; } const long double pi = M_PI; const long long big = 1LL << 50; const long long inf = 1LL << 60; const long long mod = 1e9 + 7; ll intpow(ll a, ll n, ll _mod = numeric_limits<ll>::max()) { ll p = 1; while (n) { if (n & 1) p = p * a % _mod; a = a * a % _mod; n >>= 1; } return p; } ll modc(ll a, char op, ll b, ll _mod = mod) { a %= _mod; b %= _mod; ll res = 1; switch (op) { case '+': res = (a + b) % _mod; break; case '-': res = (a - b) % _mod; break; case '*': res = a * b % _mod; break; case '/': res = modc(a, '*', modc(b, '^', _mod - 2, _mod), _mod); break; case '^': res = intpow(a, b, _mod); break; case 'P': rep(i, a - b + 1, a + 1) res = modc(res, '*', i, _mod); break; case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) { res += _mod; } return res; } template <typename T> std::map<T, T> factorint(T n) { std::map<T, T> res; for (T i = 2; i * i <= n; ++i) { T counter = 0; while (n % i == 0) { n /= i; ++counter; } if (counter != 0) { res[i] = counter; } } if (n != 1) { res[n] = 1; } return res; } int main() { ll N; cin >> N; vll cnt(1010101); rep(i, 1, 1010101) { rep(j, 1, inf) { if (i * j > 1010100) break; cnt[i * j]++; } } ll ans = 0; // rep(a, 1, 1001) { // //rep(b, 1, 1001) { // ll c = N - a*b; // if (c > 0) ++ans; // //} // } rep(c, 1, 1000001) { ll p = N - c; // auto v = factorint(p); // ll sm = 1; // for (auto x : v) { // sm *= x.second + 1; // } // ans += sm; ans += cnt[p]; } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, start, end) for (long long i = start; i < end; ++i) #define repreverse(i, start, end) for (long long i = start; i >= end; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define inrange(a, x, b) (a <= x && x <= b) #define len(x) ((long long)(x).size()) #define lcm(a, b) ((a) / __gcd((a), (b)) * (b)) using namespace std; using ll = long long; using ld = long double; using vll = vector<ll>; using vllvll = vector<vll>; using vc = vector<char>; using pll = pair<ll, ll>; template <class T> void print(T x, bool cl = 1) { cout << (cl ? "\x1b[36m" : "") << x << (cl ? "\x1b[39m" : "") << '\n'; } template <class T> void print1d(T x, ll n = -1, bool cl = true) { if (n == -1) n = x.size(); rep(i, 0, n) { cout << (cl ? "\x1b[36m" : "") << x[i] << (i == n - 1 ? '\n' : ' '); } cout << (cl ? "\x1b[39m" : ""); } template <class T> void print2d(T x, ll r = -1, ll c = -1, bool cl = 1) { if (r == -1) r = x.size(); if (c == -1) c = x[0].size(); rep(i, 0, r) print1d(x[i], c, cl); } template <class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); } template <class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.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; } template <class T> bool even(T n) { return !(n & 1); } template <class T> bool odd(T n) { return n & 1; } template <class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; } template <class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; } template <class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; } const long double pi = M_PI; const long long big = 1LL << 50; const long long inf = 1LL << 60; const long long mod = 1e9 + 7; ll intpow(ll a, ll n, ll _mod = numeric_limits<ll>::max()) { ll p = 1; while (n) { if (n & 1) p = p * a % _mod; a = a * a % _mod; n >>= 1; } return p; } ll modc(ll a, char op, ll b, ll _mod = mod) { a %= _mod; b %= _mod; ll res = 1; switch (op) { case '+': res = (a + b) % _mod; break; case '-': res = (a - b) % _mod; break; case '*': res = a * b % _mod; break; case '/': res = modc(a, '*', modc(b, '^', _mod - 2, _mod), _mod); break; case '^': res = intpow(a, b, _mod); break; case 'P': rep(i, a - b + 1, a + 1) res = modc(res, '*', i, _mod); break; case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) { res += _mod; } return res; } template <typename T> std::map<T, T> factorint(T n) { std::map<T, T> res; for (T i = 2; i * i <= n; ++i) { T counter = 0; while (n % i == 0) { n /= i; ++counter; } if (counter != 0) { res[i] = counter; } } if (n != 1) { res[n] = 1; } return res; } int main() { ll N; cin >> N; vll cnt(1010101); rep(i, 1, 1010101) { rep(j, 1, inf) { if (i * j > 1010100) break; cnt[i * j]++; } } ll ans = 0; // rep(a, 1, 1001) { // //rep(b, 1, 1001) { // ll c = N - a*b; // if (c > 0) ++ans; // //} // } rep(c, 1, 1000001) { ll p = N - c; if (p < 0) continue; // auto v = factorint(p); // ll sm = 1; // for (auto x : v) { // sm *= x.second + 1; // } // ans += sm; ans += cnt[p]; } cout << ans << endl; }
insert
146
146
146
148
-11
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; int cou = 0; cin >> n; for (int a = 1; a < n; a++) { for (int b = 1; b < n; b++) { for (int c = 1; c < n; c++) { if (a * b + c == n) { cou++; } } } } cout << cou << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; int cou = 0; cin >> n; for (int a = 1; a < n; a++) { for (int b = 1; b < n; b++) { if (a * b < n) { cou++; } else { break; } } } cout << cou << endl; }
replace
10
14
10
14
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> //{ START using namespace std; #define int int64_t #define rep(i, a, n) for (int i = (a); i < (n); ++i) #define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i) #define arep(i, x) for (auto &&i : (x)) #define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i) #define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i) // 降順はgreater<T>() #define all(x) (x).begin(), (x).end() #define rv(s) reverse((s).begin(), (s).end()) // gcd lcmはそのままok #define gcd(a, b) __gcd(a, b) #define bits(n) (1LL << (n)) #define pcnt(x) __builtin_popcountll(x) // 配列内等要素削除 #define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end()) #define Fixed(n) fixed << setprecision(n) // 総和 #define sowa(n) (((n) * ((n) + 1)) / 2) #define updiv(a, b) ((a + b - 1) / b) #define cauto const auto & using P = pair<int, int>; using Graph = vector<vector<P>>; template <class T> // 昇順 using min_heap = priority_queue<T, vector<T>, greater<T>>; template <class T> // 降順 using max_heap = priority_queue<T>; template <class A, class B> using umap = unordered_map<A, B>; template <class A> using uset = unordered_set<A>; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { // 多次元初期化 std::fill((T *)array, (T *)(array + N), val); } template <class A, class B> bool chmax(A &a, const B &b) { // 最大値更新 返り値はbool if (a < b) { a = b; return 1; } return 0; } template <class A, class B> bool chmin(A &a, const B &b) { // 最小値更新 返り値はbool if (b < a) { a = b; return 1; } return 0; } int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1}; constexpr int INF = 0x3f3f3f3f; constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int mod1 = 1e9 + 7; constexpr int mod2 = 998244353; //} END // 約数列挙 o(√n) vector<int> divisor(int n) { vector<int> res; for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { res.push_back(i); if (i != n / i) res.push_back(n / i); } } return res; } // エラトトステネスの篩を用いた高速な素因数分解 vector<int> sieve_prime_factor(size_t max) { vector<bool> IsPrime(max + 1, true); vector<int> prime(max + 1), spf(max + 1); IsPrime[0] = IsPrime[1] = false; // 0,1の初期化 for (size_t i = 2; i <= max; ++i) { if (IsPrime[i] == true) for (size_t j = i; j <= max; j += i) { IsPrime[j] = false; // 非素数を記録 prime[j] = i; // 非素数を保存 } } // prime[i]を用いて各iの素因数を列挙可能 for (size_t i = 1; i <= max; ++i) { int now = i; while (now != 1) { spf[prime[now]]++; now /= prime[now]; } } return spf; } signed main(void) { cin.tie(nullptr); ios_base::sync_with_stdio(false); int n; cin >> n; // int spf = sieve_prime_factor(n+1); int cnt = 0; if (n == 2) { cout << 1 << '\n'; return 0; } rep(i, 1, n) { auto now = divisor(n - i); cnt += now.size(); // cout << now.size() << ' '; // cout << cnt << '\n'; } cout << cnt << '\n'; return 0; }
#include <bits/stdc++.h> //{ START using namespace std; #define int int64_t #define rep(i, a, n) for (int i = (a); i < (n); ++i) #define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i) #define arep(i, x) for (auto &&i : (x)) #define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i) #define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i) // 降順はgreater<T>() #define all(x) (x).begin(), (x).end() #define rv(s) reverse((s).begin(), (s).end()) // gcd lcmはそのままok #define gcd(a, b) __gcd(a, b) #define bits(n) (1LL << (n)) #define pcnt(x) __builtin_popcountll(x) // 配列内等要素削除 #define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end()) #define Fixed(n) fixed << setprecision(n) // 総和 #define sowa(n) (((n) * ((n) + 1)) / 2) #define updiv(a, b) ((a + b - 1) / b) #define cauto const auto & using P = pair<int, int>; using Graph = vector<vector<P>>; template <class T> // 昇順 using min_heap = priority_queue<T, vector<T>, greater<T>>; template <class T> // 降順 using max_heap = priority_queue<T>; template <class A, class B> using umap = unordered_map<A, B>; template <class A> using uset = unordered_set<A>; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { // 多次元初期化 std::fill((T *)array, (T *)(array + N), val); } template <class A, class B> bool chmax(A &a, const B &b) { // 最大値更新 返り値はbool if (a < b) { a = b; return 1; } return 0; } template <class A, class B> bool chmin(A &a, const B &b) { // 最小値更新 返り値はbool if (b < a) { a = b; return 1; } return 0; } int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1}; constexpr int INF = 0x3f3f3f3f; constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int mod1 = 1e9 + 7; constexpr int mod2 = 998244353; //} END // 約数列挙 o(√n) vector<int> divisor(int n) { vector<int> res; for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { res.push_back(i); if (i != n / i) res.push_back(n / i); } } return res; } // エラトトステネスの篩を用いた高速な素因数分解 vector<int> sieve_prime_factor(size_t max) { vector<bool> IsPrime(max + 1, true); vector<int> prime(max + 1), spf(max + 1); IsPrime[0] = IsPrime[1] = false; // 0,1の初期化 for (size_t i = 2; i <= max; ++i) { if (IsPrime[i] == true) for (size_t j = i; j <= max; j += i) { IsPrime[j] = false; // 非素数を記録 prime[j] = i; // 非素数を保存 } } // prime[i]を用いて各iの素因数を列挙可能 for (size_t i = 1; i <= max; ++i) { int now = i; while (now != 1) { spf[prime[now]]++; now /= prime[now]; } } return spf; } signed main(void) { cin.tie(nullptr); ios_base::sync_with_stdio(false); int n; cin >> n; // int spf = sieve_prime_factor(n+1); int cnt = 0; rep(i, 1, n + 1) { rep(j, 1, n + 1) { if (i * j >= n) break; else ++cnt; } } cout << cnt << '\n'; return 0; }
replace
104
113
104
111
TLE
p02548
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using ll = long long; #define rep(i, n) for (ll i = 0; i < (n); i++) #define rep2(i, s, n) for (ll i = s; i < (n); i++) using namespace std; int main() { ll n; cin >> n; ll ans = 0; rep2(i, 1, n) { ll rn = sqrt(i); ll temp = 0; rep2(j, 1, rn + 1) { if (i % j == 0) temp++; } ans += temp * 2; if (i == rn * rn) ans--; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using ll = long long; #define rep(i, n) for (ll i = 0; i < (n); i++) #define rep2(i, s, n) for (ll i = s; i < (n); i++) using namespace std; int main() { ll n; cin >> n; ll ans = 0; rep2(i, 1, n) { ans += (n - 1) / i; } cout << ans << endl; return 0; }
replace
14
25
14
15
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int count = 0; for (int i = 1; i < n; i++) { for (int j = i; j < n; j++) { if (i * j < n) { count += 2; if (i == j) count--; } } } cout << count; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int count = 0; for (int i = 1; i < n; i++) { count += (n - 1) / i; } cout << count; return 0; }
replace
8
15
8
9
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long int #define li int64_t int main() { int n; cin >> n; li count = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i * j < n) { count++; } } } cout << count; }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define li int64_t int main() { int n; cin >> n; li count = n - 1; for (int i = 2; i < n; i++) { if (n % i == 0) { count += (n / i) - 1; } else { count += (n / i); } } cout << count; }
replace
9
15
9
15
TLE
p02548
C++
Time Limit Exceeded
//"BISMILLAHIR RAHMANIR RAHIM" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back const long long M = 1e9 + 7; ll fact(ll x, ll y) { ll f = 1, i = 1; while (i <= y) { f = ((f % M) * (x % M)) % M; i++; } return f; } int main() { ll n, i, cnt = 0, x, y, j; cin >> n; for (i = 1; i < n; i++) { x = n - i; for (j = 1; j * j < x; j++) { if (x % j == 0) cnt += 2; } y = sqrt(x); if (y * y == x) cnt++; } cout << cnt << endl; return 0; }
//"BISMILLAHIR RAHMANIR RAHIM" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back const long long M = 1e9 + 7; ll fact(ll x, ll y) { ll f = 1, i = 1; while (i <= y) { f = ((f % M) * (x % M)) % M; i++; } return f; } int main() { ll n, i, cnt = 0, x, y, j; cin >> n; for (i = 1; i < n; i++) { for (j = 1; i * j < n; j++) cnt++; } cout << cnt << endl; return 0; }
replace
18
25
18
19
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef map<string, int> msi; typedef pair<int, int> PII; int main() { int n; cin >> n; ll ans = 0; for (int i = 1; i < n; i++) { for (int j = 1; j <= pow(n - i, 0.5); j++) { if ((n - i) % j == 0) { if ((double)j != pow(n - i, 0.5)) ans += 2; else ans++; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef map<string, int> msi; typedef pair<int, int> PII; int main() { int n; cin >> n; ll ans = 0; for (int i = 1; i < n; i++) { ans += ((n - 1) / i); } cout << ans << endl; return 0; }
replace
13
21
13
14
TLE
p02548
C++
Time Limit Exceeded
// author: vinoda #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long count = 0; for (int i = 1; i <= 1e6; ++i) { if (i > n) break; for (int j = 1; j <= 1e6; ++j) { if (j > n) break; int c = n - i * j; if (c > 0) ++count; } } cout << count << endl; }
// author: vinoda #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long count = 0; for (int i = 1; i < n; ++i) count += (n - 1) / i; cout << count << endl; }
replace
8
19
8
10
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <iostream> #include <iterator> #include <map> #include <math.h> #include <set> #include <string> #include <vector> #define ll long long int #define ull unsigned long long int #define pb push_back #define mp make_pair #include <algorithm> #include <cmath> using namespace std; pair<ll, ll> norm(ll a, ll b) { if (a < 0) { a *= -1; b *= -1; } else if ((a == 0) && (b < 0)) { b *= -1; } ll d = __gcd(abs(a), abs(b)); a = (ll)(a / d); b = (ll)(b / d); pair<ll, ll> p = mp(a, b); return p; } bool decreasing(pair<ll, ll> a, pair<ll, ll> b) { if (a.first > b.first) return true; else if (a.first == b.first) { if (a.second < b.second) return false; else return true; } else return false; } ll expo(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res * x) % 1000000007; y = y >> 1; x = (x * x) % 1000000007; } return res; } int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); // int T,p; // cin>>T; // for(p=1;p<=T;p++) // { ll N; cin >> N; ll i, j, k, a, b, c; ll count = 0; for (i = 1; i < N; i++) { a = N - i; for (j = 1; j * j <= a; j++) { if (a % j == 0) { k = a / j; if (k == j) count++; else count += 2; } } } cout << count; return 0; }
#include <bits/stdc++.h> #include <iostream> #include <iterator> #include <map> #include <math.h> #include <set> #include <string> #include <vector> #define ll long long int #define ull unsigned long long int #define pb push_back #define mp make_pair #include <algorithm> #include <cmath> using namespace std; pair<ll, ll> norm(ll a, ll b) { if (a < 0) { a *= -1; b *= -1; } else if ((a == 0) && (b < 0)) { b *= -1; } ll d = __gcd(abs(a), abs(b)); a = (ll)(a / d); b = (ll)(b / d); pair<ll, ll> p = mp(a, b); return p; } bool decreasing(pair<ll, ll> a, pair<ll, ll> b) { if (a.first > b.first) return true; else if (a.first == b.first) { if (a.second < b.second) return false; else return true; } else return false; } ll expo(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res * x) % 1000000007; y = y >> 1; x = (x * x) % 1000000007; } return res; } int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); // int T,p; // cin>>T; // for(p=1;p<=T;p++) // { ll N; cin >> N; ll i, j, k, a, b, c; ll count = 0; for (i = 1; i < N; i++) { a = N - 1; b = (ll)(a / i); count += b; } cout << count; return 0; }
replace
61
71
61
64
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long n, j, i, p = 0, k, l; cin >> n; for (i = 1; i <= n - 1; i++) { k = n - i; for (j = 1; j <= sqrt(k); j++) { if (k % j == 0) { if (j * j == k) p = p + 1; else p = p + 2; } } } cout << p; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, j, i, p = 0, k, l; cin >> n; p = p; for (i = 1; i <= n; i++) { p = p + n / i; if (n % i == 0) { p = p - 1; } } cout << p; return 0; }
replace
5
14
5
10
TLE
p02548
C++
Time Limit Exceeded
// #pragma GCC optimize("Ofast") // #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("O3") #include <algorithm> #include <chrono> #include <cmath> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr auto INF = 9223372036854775807; typedef long long int ll; typedef unsigned long long int ull; typedef unsigned long int ul; #define f(i, a, b) for (ll i = (ll)a; i < (ll)b; i += 1) #define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i -= 1) #define endl '\n' #define N 1000000007 // prime modulo value #define M 998244353 #define all(x) x.begin(), x.end() #define mkp(a, b) make_pair(a, b) using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; inline int mex(unordered_set<int> st) { int m = 0; while (st.find(m) != st.end()) { m += 1; } return m; } inline int calculateGrundy(int n) { if (n == 1) return 0; unordered_set<int> mexi; for (int i = 1; i <= sqrt(n); i += 1) { if (n % i == 0) { if (n / i != n) mexi.insert(calculateGrundy(n / i)); mexi.insert(calculateGrundy(i)); } } return mex(mexi); } inline ll gcd(ll a, ll b) { // This is code taken from geeksforgeek if (b == 0) return a; return gcd(b, a % b); } /*ll power(ll x, ll y) { // This is code taken from geeksforgeek ll res = 1; x = x % N; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % N; y = y >> 1; x = (x * x) % N; } return res; }*/ ll power(ll x, ll y) { ll res = 1; x = x; while (y > 0) { if (y & 1) res = (res * x); y = y >> 1; x = (x * x); } return res; } /*ll modInverse(ll n, ll p) { return power(n, p - 2, p); }*/ ll sum(ll n) { return (n * (n + 1)) / 2; } ll sum_digit(ll n) { ll ans = 0; while (n) { ans += n % 10; n /= 10; } return ans; } ll num_of_divisors(ll n) { unordered_set<ll> st; for (ll i = 1; i <= sqrt(n); i++) { if (n % i == 0) { st.insert(i); st.insert(n / i); } } return st.size(); } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll n; cin >> n; ll ans = 0; f(i, 1, n) { f(j, 1, n) { if (i * j < n) ans += 1; } } cout << ans; return 0; }
// #pragma GCC optimize("Ofast") // #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("O3") #include <algorithm> #include <chrono> #include <cmath> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr auto INF = 9223372036854775807; typedef long long int ll; typedef unsigned long long int ull; typedef unsigned long int ul; #define f(i, a, b) for (ll i = (ll)a; i < (ll)b; i += 1) #define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i -= 1) #define endl '\n' #define N 1000000007 // prime modulo value #define M 998244353 #define all(x) x.begin(), x.end() #define mkp(a, b) make_pair(a, b) using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; inline int mex(unordered_set<int> st) { int m = 0; while (st.find(m) != st.end()) { m += 1; } return m; } inline int calculateGrundy(int n) { if (n == 1) return 0; unordered_set<int> mexi; for (int i = 1; i <= sqrt(n); i += 1) { if (n % i == 0) { if (n / i != n) mexi.insert(calculateGrundy(n / i)); mexi.insert(calculateGrundy(i)); } } return mex(mexi); } inline ll gcd(ll a, ll b) { // This is code taken from geeksforgeek if (b == 0) return a; return gcd(b, a % b); } /*ll power(ll x, ll y) { // This is code taken from geeksforgeek ll res = 1; x = x % N; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % N; y = y >> 1; x = (x * x) % N; } return res; }*/ ll power(ll x, ll y) { ll res = 1; x = x; while (y > 0) { if (y & 1) res = (res * x); y = y >> 1; x = (x * x); } return res; } /*ll modInverse(ll n, ll p) { return power(n, p - 2, p); }*/ ll sum(ll n) { return (n * (n + 1)) / 2; } ll sum_digit(ll n) { ll ans = 0; while (n) { ans += n % 10; n /= 10; } return ans; } ll num_of_divisors(ll n) { unordered_set<ll> st; for (ll i = 1; i <= sqrt(n); i++) { if (n % i == 0) { st.insert(i); st.insert(n / i); } } return st.size(); } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll n; cin >> n; ll ans = 0; f(i, 1, n) { for (ll j = 1; i * j < n; j++) { ans++; } } cout << ans; return 0; }
replace
138
141
138
140
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int cnt = 0; for (long long int i = 1; i <= n; i++) { for (long long int j = 1; j <= n; j++) { for (long long int k = 1; k <= n; k++) { if ((i * j) + k == n) { cnt++; } } } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int cnt = 0; for (long long int i = 1; i < n; i++) { for (long long int j = 1; i * j < n; j++) { cnt++; } } cout << cnt << endl; }
replace
6
13
6
9
TLE
p02548
C++
Runtime Error
#pragma GCC optimize(2) #include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> #define File(x) freopen(x ".in", "r", stdin), freopen(x ".out", "w", stdout); #define re register #define ri re int #define gtch() \ (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) \ ? EOF \ : *p1++) #define For(i, a, b) for (ri i = a; i <= b; ++i) #define iFor(i, a, b) for (ri i = a; i >= b; --i) using namespace std; typedef long long ll; char buf[1 << 21], *p1 = buf, *p2 = buf; inline ll fr() { re char ch = getchar(); re ll res = 0; int bl = 0; while (!isdigit(ch)) bl = (ch == '-'), ch = getchar(); while (isdigit(ch)) res = (res << 1) + (res << 3) + ch - '0', ch = getchar(); return bl ? -res : res; } const int MAXN = 1e7; int mf[MAXN]; ll prime[MAXN], tot; ll d[MAXN], cnt[MAXN]; int n; inline void sieve() { d[1] = 1; for (ri i = 2; i <= n; ++i) { if (!mf[i]) { mf[i] = i, prime[++tot] = i, d[i] = 2, cnt[i] = 1; } // cout<<i<<" "<<d[i]<<" "<<cnt[i]<<"\n"; for (ri j = 1; j <= tot; ++j) { ri p = prime[j], t = i * p; mf[t] = p; if (p == mf[i]) { cnt[t] = cnt[i] + 1, d[t] = d[i] / (cnt[i] + 1) * (cnt[i] + 2); break; } cnt[t] = 1, d[t] = d[i] * 2; } } } signed main() { // File("temp") n = fr(); sieve(); ll ans = 0; for (ri i = 1; i < n; ++i) ans += d[i]; cout << ans; return 0; }
#pragma GCC optimize(2) #include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> #define File(x) freopen(x ".in", "r", stdin), freopen(x ".out", "w", stdout); #define re register #define ri re int #define gtch() \ (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) \ ? EOF \ : *p1++) #define For(i, a, b) for (ri i = a; i <= b; ++i) #define iFor(i, a, b) for (ri i = a; i >= b; --i) using namespace std; typedef long long ll; char buf[1 << 21], *p1 = buf, *p2 = buf; inline ll fr() { re char ch = getchar(); re ll res = 0; int bl = 0; while (!isdigit(ch)) bl = (ch == '-'), ch = getchar(); while (isdigit(ch)) res = (res << 1) + (res << 3) + ch - '0', ch = getchar(); return bl ? -res : res; } const int MAXN = 1e7; int mf[MAXN]; ll prime[MAXN], tot; ll d[MAXN], cnt[MAXN]; int n; inline void sieve() { d[1] = 1; for (ri i = 2; i <= n; ++i) { if (!mf[i]) { mf[i] = i, prime[++tot] = i, d[i] = 2, cnt[i] = 1; } // cout<<i<<" "<<d[i]<<" "<<cnt[i]<<"\n"; for (ri j = 1; j <= tot; ++j) { ri p = prime[j], t = i * p; if (t > n) break; mf[t] = p; if (p == mf[i]) { cnt[t] = cnt[i] + 1, d[t] = d[i] / (cnt[i] + 1) * (cnt[i] + 2); break; } cnt[t] = 1, d[t] = d[i] * 2; } } } signed main() { // File("temp") n = fr(); sieve(); ll ans = 0; for (ri i = 1; i < n; ++i) ans += d[i]; cout << ans; return 0; }
insert
42
42
42
44
-11
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define ll long long int #define pb push_back int main() { ll a, cnt = 0; cin >> a; for (ll i = 1; i < a; i++) { ll cur = a - i; for (ll j = 1; j <= sqrt(cur); j++) { if (j * j == cur) cnt++; else if (cur % j == 0) cnt += 2; } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define ll long long int #define pb push_back int main() { ll a, cnt = 0; cin >> a; for (ll i = 1; i <= a; i++) { cnt += a / i; if (a % i == 0) cnt--; } cout << cnt << endl; }
replace
9
17
9
13
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int count = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (n - (i * j) > 0) { count++; } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int count = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n / i; j++) { if (n - (i * j) > 0) { count++; } } } cout << count << endl; }
replace
7
8
7
8
TLE
p02548
C++
Time Limit Exceeded
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <stack> #include <string> #include <unordered_map> using namespace std; typedef long long ll; const ll INF = 1000000007; const ll mod = 1000000007; #define rep(i, n) for (int i = 0; i < (n); ++i) int main() { ll N; cin >> N; ll ans = 0; for (int i = 1; i <= N; i++) { for (int a = 1; a <= N - i; a++) { if ((N - i) % a == 0) ans++; } } cout << ans << endl; return 0; }
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <stack> #include <string> #include <unordered_map> using namespace std; typedef long long ll; const ll INF = 1000000007; const ll mod = 1000000007; #define rep(i, n) for (int i = 0; i < (n); ++i) int main() { ll N; cin >> N; ll ans = 0; for (int i = 1; i < N; i++) { ans += floor((double)(N - 1) / i); } cout << ans << endl; return 0; }
replace
23
28
23
25
TLE
p02548
C++
Time Limit Exceeded
/* https://codeforces.com/contest/1360/problem/H */ #include <bits/stdc++.h> using namespace std; using ll = long long; using vs = vector<string>; using vi = vector<int>; using vl = vector<ll>; using vb = vector<bool>; using pi = pair<int, int>; using pl = pair<ll, ll>; using vpi = vector<pair<int, int>>; using vpl = vector<pair<ll, ll>>; using ld = double; #define f first #define s second #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i) #define pb push_back #define lb lower_bound #define ub upper_bound #define sz(x) (int)(x).size() #define all(x) x.begin(), x.end() #define ins insert const int MAX = INT_MAX; const int MOD = 998244353; int main() { int N; cin >> N; int ans = 0; for (int i = 1; i <= N; ++i) for (int j = 1; j <= N; ++j) for (int k = 1; k <= N; ++k) if (j * i + k == N) ans++; cout << ans << endl; return 0; }
/* https://codeforces.com/contest/1360/problem/H */ #include <bits/stdc++.h> using namespace std; using ll = long long; using vs = vector<string>; using vi = vector<int>; using vl = vector<ll>; using vb = vector<bool>; using pi = pair<int, int>; using pl = pair<ll, ll>; using vpi = vector<pair<int, int>>; using vpl = vector<pair<ll, ll>>; using ld = double; #define f first #define s second #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i) #define pb push_back #define lb lower_bound #define ub upper_bound #define sz(x) (int)(x).size() #define all(x) x.begin(), x.end() #define ins insert const int MAX = INT_MAX; const int MOD = 998244353; int main() { int N; cin >> N; int ans = 0; for (int i = 1; i < N; ++i) for (int j = 1; i * j < N; ++j) ans++; cout << ans << endl; return 0; }
replace
35
40
35
38
TLE
p02548
C++
Time Limit Exceeded
#include <stdio.h> #include <string.h> #pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define rep(i, N) for (int i = 0; i < (int)N; i++) static inline void PUT(char c) { static char buf[1 << 15], *ptr = buf; if (ptr == buf + strlen(buf) || c == 0) { fwrite(buf, 1, ptr - buf, stdout), ptr = buf; } *ptr++ = c; } static inline int IN(void) { int x = 0, f = 0, c = getchar(); while (c < 48 || c > 57) { f ^= c == 45, c = getchar(); } while (c > 47 && c < 58) { x = x * 10 + c - 48, c = getchar(); } return f ? -x : x; } static inline void OUT(int a) { if (a < 0) PUT('-'), a = -a; int d[40], i = 0; do { d[i++] = a % 10; } while (a /= 10); while (i--) { PUT(d[i] + 48); } PUT('\n'); } int main() { int N = IN(), count = 0; rep(i, N) rep(j, N) rep(k, N) { if ((i + 1) * (j + 1) + k + 1 == N) { count++; } } return OUT(count), 0; }
#include <stdio.h> #include <string.h> #pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define rep(i, N) for (int i = 0; i < (int)N; i++) static inline void PUT(char c) { static char buf[1 << 15], *ptr = buf; if (ptr == buf + strlen(buf) || c == 0) { fwrite(buf, 1, ptr - buf, stdout), ptr = buf; } *ptr++ = c; } static inline int IN(void) { int x = 0, f = 0, c = getchar(); while (c < 48 || c > 57) { f ^= c == 45, c = getchar(); } while (c > 47 && c < 58) { x = x * 10 + c - 48, c = getchar(); } return f ? -x : x; } static inline void OUT(int a) { if (a < 0) PUT('-'), a = -a; int d[40], i = 0; do { d[i++] = a % 10; } while (a /= 10); while (i--) { PUT(d[i] + 48); } PUT('\n'); } int main() { int N = IN(), count = 0; rep(i, N - 1) { count += (N - 1) / (i + 1); } return OUT(count), 0; }
replace
36
41
36
37
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vector<int>>; using vvvi = vector<vector<vector<int>>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; using vvvl = vector<vector<vector<ll>>>; using vs = vector<string>; using vb = vector<bool>; #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 REP(i, n) FOR(i, 0, (n)) #define REPR(i, n) FORR(i, (n)-1, 0) #define REP1(i, n) FOR(i, 1, (n) + 1) #define REPS(c, s) for (char c : s) #define ALL(c) (c).begin(), (c).end() #define SORT(c) sort(ALL(c)) #define REV(c) reverse(ALL(c)) #define sz(v) (int)v.size() #define endl '\n' 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; } template <class T> inline void prn(vector<T> &v) { int n = sz(v); REP(i, n) cout << v[i] << ' '; } template <class T> inline void printv(vector<T> &v) { int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' '); } template <class T> inline void printvv(vector<vector<T>> &v) { for (auto u : v) printv(u); } template <class T> inline void printlnv(vector<T> &v) { int n = sz(v); REP(i, n) cout << v[i] << endl; } const int MOD = 1000000007; const int INF = 1000000001; const ll LINF = 1000000001000000001LL; void solve(); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(numeric_limits<double>::max_digits10); solve(); return 0; } vector<ll> divisors(ll n) { vector<ll> v; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { v.push_back(i); if (i * i != n) { v.push_back(n / i); } } } return v; } map<ll, ll> prime_factorization(ll n) { map<ll, ll> m; ll x = n; ll d = 2; while (x > 1 && d * d <= n) { if (x % d == 0) { m[d]++; x /= d; } else { d++; } } if (x != 1) m[x]++; return m; } void solve() { int n; cin >> n; int ans = 0; vector<map<ll, ll>> memo(n + 1); for (int c = n - 1; c > 0; c--) { int x = n - c; if (x % 2 == 0) { auto z = memo[x / 2]; z[2]++; memo[x] = z; } else if (x % 3 == 0) { auto z = memo[x / 3]; z[3]++; memo[x] = z; } else { auto d = prime_factorization(x); memo[x] = d; } if (x == 1) ans++; else { int s = 1; for (auto t : memo[x]) s *= t.second + 1; ans += s; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vector<int>>; using vvvi = vector<vector<vector<int>>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; using vvvl = vector<vector<vector<ll>>>; using vs = vector<string>; using vb = vector<bool>; #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 REP(i, n) FOR(i, 0, (n)) #define REPR(i, n) FORR(i, (n)-1, 0) #define REP1(i, n) FOR(i, 1, (n) + 1) #define REPS(c, s) for (char c : s) #define ALL(c) (c).begin(), (c).end() #define SORT(c) sort(ALL(c)) #define REV(c) reverse(ALL(c)) #define sz(v) (int)v.size() #define endl '\n' 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; } template <class T> inline void prn(vector<T> &v) { int n = sz(v); REP(i, n) cout << v[i] << ' '; } template <class T> inline void printv(vector<T> &v) { int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' '); } template <class T> inline void printvv(vector<vector<T>> &v) { for (auto u : v) printv(u); } template <class T> inline void printlnv(vector<T> &v) { int n = sz(v); REP(i, n) cout << v[i] << endl; } const int MOD = 1000000007; const int INF = 1000000001; const ll LINF = 1000000001000000001LL; void solve(); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(numeric_limits<double>::max_digits10); solve(); return 0; } vector<ll> divisors(ll n) { vector<ll> v; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { v.push_back(i); if (i * i != n) { v.push_back(n / i); } } } return v; } map<ll, ll> prime_factorization(ll n) { map<ll, ll> m; ll x = n; ll d = 2; while (x > 1 && d * d <= n) { if (x % d == 0) { m[d]++; x /= d; } else { d++; } } if (x != 1) m[x]++; return m; } void solve() { int n; cin >> n; int ans = 0; vector<map<ll, ll>> memo(n + 1); for (int c = n - 1; c > 0; c--) { int x = n - c; if (x % 2 == 0) { auto z = memo[x / 2]; z[2]++; memo[x] = z; } else if (x % 3 == 0) { auto z = memo[x / 3]; z[3]++; memo[x] = z; } else if (x % 5 == 0) { auto z = memo[x / 5]; z[5]++; memo[x] = z; } else if (x % 7 == 0) { auto z = memo[x / 7]; z[7]++; memo[x] = z; } else { auto d = prime_factorization(x); memo[x] = d; } if (x == 1) ans++; else { int s = 1; for (auto t : memo[x]) s *= t.second + 1; ans += s; } } cout << ans << endl; }
insert
113
113
113
121
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define int long long using namespace std; inline int read() { int s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } inline bool read(int &a) { int s = 0, w = 1; char ch = getchar(); if (ch == EOF) { return false; } while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); a = s * w; return true; } inline void write(int x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } inline void writeln(int x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); puts(""); } signed main() { int n = read(); int ans = 0; for (register int i = 1; i <= n - 1; i++) { int now = n - i; for (register int j = 1; j * j <= now; j++) { if (now % j == 0 && now != j * j) ans += 2; else if (now % j == 0) ans++; } } writeln(ans); return 0; }
#include <bits/stdc++.h> #define int long long using namespace std; inline int read() { int s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } inline bool read(int &a) { int s = 0, w = 1; char ch = getchar(); if (ch == EOF) { return false; } while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); a = s * w; return true; } inline void write(int x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } inline void writeln(int x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); puts(""); } signed main() { int n = read(); int ans = 0; for (register int i = 1; i < n; i++) { ans += n / i; if (n % i == 0) ans--; } writeln(ans); return 0; }
replace
56
64
56
60
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0; cin >> n; for (int a = 1; a <= n; a++) { for (int b = 1; b <= n; b++) { ans += n - a * b > 0; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0; cin >> n; for (int a = 1; a <= n; a++) { for (int b = 1; b <= n; b++) { if (a * b < n) ans++; else break; } } cout << ans << endl; }
replace
10
11
10
14
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ tree_order_statistics_node_update> using namespace std; #define ll long long int #define ld long double #define ff first #define ss second #define endl '\n' #define pb push_back #define t_case \ ll tt; \ cin >> tt; \ while (tt--) #define all(v) v.begin(), v.end() #define ub(a, x) upper_bound(all(a), x) - a.begin() #define lb(a, x) lower_bound(all(a), x) - a.begin() #define fr(a, b, c) for (ll a = b; a < c; a++) #define take(xx, n) \ for (int i = 0; i < n; i++) \ cin >> xx[i]; #define take1(xx, n) \ for (int i = 1; i <= n; i++) \ cin >> xx[i]; #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); const auto inf = LLONG_MAX; int main() { fastio // t_case { ll sum = 0, f = 1, ans = 0, n, m = 1, mx = -inf, mn = inf, x, y, k; cin >> n; fr(i, 1, n) { for (int j = 1; j * j <= i; j++) { if (i % j == 0) { if ((i / j) == j) ans++; else ans += 2; } } } cout << ans; cout << endl; } return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ tree_order_statistics_node_update> using namespace std; #define ll long long int #define ld long double #define ff first #define ss second #define endl '\n' #define pb push_back #define t_case \ ll tt; \ cin >> tt; \ while (tt--) #define all(v) v.begin(), v.end() #define ub(a, x) upper_bound(all(a), x) - a.begin() #define lb(a, x) lower_bound(all(a), x) - a.begin() #define fr(a, b, c) for (ll a = b; a < c; a++) #define take(xx, n) \ for (int i = 0; i < n; i++) \ cin >> xx[i]; #define take1(xx, n) \ for (int i = 1; i <= n; i++) \ cin >> xx[i]; #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); const auto inf = LLONG_MAX; int main() { fastio // t_case { ll sum = 0, f = 1, ans = 0, n, m = 1, mx = -inf, mn = inf, x, y, k; cin >> n; for (int i = 1; i < n; i++) { ans = ans + ((n - 1) / i); } cout << ans; cout << endl; } return 0; }
replace
40
49
40
42
TLE
p02548
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define sz(x) ((int)(x).size()) #define mt make_tuple #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i) using namespace std; typedef long long lld; typedef vector<lld> vlld; const lld mod = (lld)1e9 + 7; int main() { lld n; cin >> n; lld ans = 0; for (int i = 1; i <= n; i++) { lld c = n - i; for (int j = 1; j * j <= c; j++) { if (c % j == 0) { if (c / j == j) ans++; else ans += 2; } } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> #define sz(x) ((int)(x).size()) #define mt make_tuple #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i) using namespace std; typedef long long lld; typedef vector<lld> vlld; const lld mod = (lld)1e9 + 7; int main() { lld n; cin >> n; lld ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (n <= i * j) break; ans++; } } cout << ans << "\n"; return 0; }
replace
23
31
23
27
TLE
p02548
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <vector> #define DOLL long double #define LOLI long long int using namespace std; const long C_10PW9 = 1000000000; const int ULCODE = 32; int divc(int s) { int r = 0; int sq = sqrt(s); for (int i = 1; i <= sq; i++) { if (s % i == 0) { r++; if (s / i != i) { r++; } } } return r; } int main() { int n; cin >> n; int f = 0; for (int i = 1; i < n; i++) { f += divc(i); } cout << f << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <vector> #define DOLL long double #define LOLI long long int using namespace std; const long C_10PW9 = 1000000000; const int ULCODE = 32; int divc(int s) { int r = 0; int sq = sqrt(s); for (int i = 1; i <= sq; i++) { if (s % i == 0) { r++; if (s / i != i) { r++; } } } return r; } int main() { int n; cin >> n; int f = 0; for (int i = 1; i < n; i++) { int a = (n - 1) / i; f += a; } cout << f << endl; return 0; }
replace
32
33
32
34
TLE