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
p03048
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int i = 0; i <= N / R; ++i) { for (int j = 0; j <= N / G; ++j) { for (int k = 0; k <= N / B; ++k) { if (R * i + G * j + B * k == N) ans++; } } } cout << ans << endl; return 0; }
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int i = 0; i <= N / R; ++i) { for (int j = 0; j <= N / G; ++j) { if ((N - R * i - G * j) % B == 0 && (N - R * i - G * j) / B >= 0) ans++; } } cout << ans << endl; return 0; }
replace
10
14
10
12
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define loop(i, a, b) for (int i = a; i < b; i++) #define test() \ int t; \ cin >> t; \ loop(test, 1, t + 1) #define pb push_back #define eb emplace_back #define mkp make_pair #define nl cout << "\n" #define sp cout << " " #define F first #define S second #define vi vector<int> #define vl vector<ll> #define pii pair<int, int> #define pll pair<ll, ll> #define vii vector<pii> #define vll vector<pll> #define prsp(v) \ loop(i, 0, v.size()) cout << v[i], sp; \ nl; #define prpsp(v) \ loop(i, 0, v.size()) cout << v[i].F << " " << v[i].S << " , "; \ nl; #define prnl(v) \ loop(i, 0, v.size()) cout << v[i], nl; \ nl; #define prpnl(v) \ loop(i, 0, v.size()) cout << v[i].F << " " << v[i].S, nl; \ nl; #define MOD 1000000007 #define mod(n) (((n % MOD) + MOD) % MOD) #define all(x) x.begin(), x.end() const int N = 1e5 + 5; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; ll c2(ll n) { ll ans = n * (n - 1); ans /= 2; return ans; } int main() { fastio(); ll r, g, b, n; cin >> r >> g >> b >> n; ll ans = 0; loop(i, 0, n / r + 1) { ll rem = n - r * i; loop(j, 0, rem / g + 1) { ll remm = rem - j * g; loop(k, 0, remm / b + 1) { ll remmm = remm - k * b; if (remmm == 0) ans++; } } } cout << ans, nl; cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; return 0; }
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define loop(i, a, b) for (int i = a; i < b; i++) #define test() \ int t; \ cin >> t; \ loop(test, 1, t + 1) #define pb push_back #define eb emplace_back #define mkp make_pair #define nl cout << "\n" #define sp cout << " " #define F first #define S second #define vi vector<int> #define vl vector<ll> #define pii pair<int, int> #define pll pair<ll, ll> #define vii vector<pii> #define vll vector<pll> #define prsp(v) \ loop(i, 0, v.size()) cout << v[i], sp; \ nl; #define prpsp(v) \ loop(i, 0, v.size()) cout << v[i].F << " " << v[i].S << " , "; \ nl; #define prnl(v) \ loop(i, 0, v.size()) cout << v[i], nl; \ nl; #define prpnl(v) \ loop(i, 0, v.size()) cout << v[i].F << " " << v[i].S, nl; \ nl; #define MOD 1000000007 #define mod(n) (((n % MOD) + MOD) % MOD) #define all(x) x.begin(), x.end() const int N = 1e5 + 5; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; ll c2(ll n) { ll ans = n * (n - 1); ans /= 2; return ans; } int main() { fastio(); ll r, g, b, n; cin >> r >> g >> b >> n; ll ans = 0; loop(i, 0, n / r + 1) { ll rem = n - r * i; loop(j, 0, rem / g + 1) { ll remm = rem - j * g; if (remm % b == 0) ans++; } } cout << ans, nl; cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; return 0; }
replace
64
69
64
66
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int RR = N / R + 1; int GG = N / G + 1; int BB = N / B + 1; int count = 0; for (int i = 0; i < RR; i++) { for (int j = 0; j < (N - R * i) / G + 1; j++) { for (int k = 0; k < (N - R * i - G * j) / B + 1; k++) { if ((N - R * i - G * j) % B != 0) { break; } if (R * i + G * j + B * k == N) { count++; } } } } cout << count << endl; }
#include <iostream> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int RR = N / R + 1; int GG = N / G + 1; int BB = N / B + 1; int count = 0; for (int i = 0; i < RR; i++) { for (int j = 0; j < (N - R * i) / G + 1; j++) { if ((N - R * i - G * j) % B == 0) { count++; } } } cout << count << endl; }
replace
14
21
14
16
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int r, g, b, n, ans = 0; cin >> r >> g >> b >> n; for (int i = 0; i <= n / r; i++) { for (int j = 0; j <= (n - i * r) / g; j++) { for (int k = 0; k <= (n - i * r - j * g) / b; k++) { if (i * r + j * g + k * b == n) { ans++; } } } } cout << ans << endl; return 0; }
#include <iostream> using namespace std; int main() { int r, g, b, n, ans = 0; cin >> r >> g >> b >> n; for (int i = 0; i <= n / r; i++) { for (int j = 0; j <= (n - i * r) / g; j++) { if ((n - i * r - j * g) % b == 0) { ans++; } } } cout << ans << endl; return 0; }
replace
8
12
8
10
TLE
p03048
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 r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; for (int i = 0; i * r <= n; i++) { for (int j = 0; j * g <= (n - i * r); j++) { for (int k = 0; k * b <= (n - i * r - j * g); k++) { // cout << i << j << k << endl; int ri = r * i; int gj = g * j; int bk = b * k; ll clac = ri + gj + bk; if (n == clac) { ans++; } } } } cout << ans << endl; return 0; } /* やっほい!        やほほい!     +    *     ∧∧  . ∧∞∧ * * ヽ(=´ω`)人(´ω`*)ノ  .~( O x.) (   O)~ + 。*   ∪    ∪ */
#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 r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; for (int i = 0; i * r <= n; i++) { for (int j = 0; j * g <= (n - i * r); j++) { /*for(int k = 0; k*b <= (n-i*r-j*g) ;k++){ //cout << i << j << k << endl; int ri = r*i; int gj = g*j; int bk = b*k; ll clac = ri+gj+bk; if(n == clac){ ans++; }*/ if ((n - (i * r + j * g)) % b == 0) { ans++; } } } cout << ans << endl; return 0; } /* やっほい!        やほほい!     +    *     ∧∧  . ∧∞∧ * * ヽ(=´ω`)人(´ω`*)ノ  .~( O x.) (   O)~ + 。*   ∪    ∪ */
replace
12
21
12
23
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int r, g, b, count = 0; for (r = 0; r * R <= N; r++) { for (g = 0; r * R + g * G <= N; g++) { for (b = 0; r * R + g * G + b * B <= N; b++) { if (r * R + g * G + b * B == N) { count++; } } } } cout << count << endl; return 0; }
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int r, g, b, count = 0; for (r = 0; r * R <= N; r++) { for (g = 0; r * R + g * G <= N; g++) { if ((N - r * R - g * G) % B == 0) { count++; } } } cout << count << endl; return 0; }
replace
10
14
10
12
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b, n, i, j, k, ans = 0; cin >> r >> g >> b >> n; for (i = 0; i <= n / r; i++) { for (j = 0; j <= n - i * r && j <= n / g; j++) { for (k = 0; k <= n - i * r - j * g && k <= n / b; k++) { if (i * r + j * g + k * b == n) { ans++; } } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b, n, i, j, k, ans = 0; cin >> r >> g >> b >> n; for (i = 0; i <= n / r; i++) { for (j = 0; j <= n - i * r; j++) { if ((n - (i * r + j * g)) % b == 0 && n - (i * r + j * g) >= 0) { ans++; } } } cout << ans << endl; }
replace
8
13
8
11
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> int main() { int R, G, B, N; scanf("%d %d %d %d", &R, &G, &B, &N); int r, g, b, cnt; cnt = 0; for (r = 0; r * R <= N; r++) { for (g = 0; r * R + g * G <= N; g++) { for (b = 0; r * R + g * G + B * b <= N; b++) { if (R * r + G * g + B * b == N) { cnt++; } } } } printf("%d", cnt); return 0; }
#include <iostream> int main() { int R, G, B, N; scanf("%d %d %d %d", &R, &G, &B, &N); int r, g, b, cnt; for (r = 0; R * r <= N; r++) { for (g = 0; R * r + G * g <= N; g++) { if ((N - (R * r + G * g)) % B == 0) { cnt++; } } } printf("%d", cnt); return 0; }
replace
9
17
9
13
TLE
p03048
Python
Time Limit Exceeded
R, G, B, N = map(int, input().split()) ans = 0 for i in range(N // R + 1): N_R = N - i * R for j in range(N_R // G + 1): N_RG = N_R - j * G for k in range(N_RG // B + 1): N_RGB = N_RG - k * B if N_RGB == 0: ans += 1 print(ans)
R, G, B, N = map(int, input().split()) ans = 0 for i in range(N // R + 1): for j in range((N - i * R) // G + 1): if (N - i * R - j * G) % B == 0: ans += 1 print(ans)
replace
4
11
4
7
TLE
p03048
Python
Time Limit Exceeded
R, G, B, N = map(int, input().split()) ans = 0 for i in range(int(N / R) + 1): for j in range(int((N - i * R) / G) + 1): if (N - (i * R + j * G)) % B == 0 and (N - (i * R + j * G)) >= 0: ans += 1 print(ans)
R, G, B, N = map(int, input().split()) ans = 0 for i in range(int(N / R) + 1): for j in range(int((N - i * R) / G) + 1): if (N - (i * R + j * G)) % B == 0: ans += 1 print(ans)
replace
5
6
5
6
TLE
p03048
Python
Time Limit Exceeded
R, G, B, N = map(int, input().split()) LIM = 3003 ans = 0 for r in range(LIM): for g in range(LIM): if R * r + G * g > N: break Bb = N - R * r - G * g if Bb % B == 0: ans += 1 print(ans)
def solve(): R, G, B, N = map(int, input().split()) LIM = 3001 ans = 0 for r in range(LIM): for g in range(LIM): if R * r + G * g > N: break Bb = N - R * r - G * g if Bb % B == 0: ans += 1 return ans print(solve())
replace
0
11
0
15
TLE
p03048
Python
Time Limit Exceeded
R, G, B, N = map(int, input().split()) res = 0 for i in range(N // R + 1): for j in range(N // G + 1): b = N - R * i - G * j if b >= 0 and b % B == 0: res += 1 print(res)
R, G, B, N = map(int, input().split()) res = 0 for i in range(N // R + 1): for j in range((N - R * i) // G + 1): b = N - R * i - G * j if b >= 0 and b % B == 0: res += 1 print(res)
replace
5
6
5
6
TLE
p03048
Python
Time Limit Exceeded
# from time import perf_counter def main(): r, g, b, n = list(map(int, input().split())) count = 0 x1, x2, x3 = sorted([r, g, b], reverse=True) # print(x1, x2, x3) for i in range(n // x1 + 1): for j in range((n - i) // x2 + 1): for k in range((n - i - j) // x3 + 1): # print(f'{r}*{i} + {g}*{j} + {b}*{k} = {r*i+g*j+k+b*k}') if x1 * i + x2 * j + x3 * k == n: count += 1 print(count) if __name__ == "__main__": # s = perf_counter() main() # e = perf_counter() # print('process:', e - s)
# from time import perf_counter def main(): r, g, b, n = list(map(int, input().split())) count = 0 x1, x2, x3 = sorted([r, g, b], reverse=True) # print(x1, x2, x3) for i in range(n // x1 + 1): for j in range((n - i) // x2 + 1): rest = n - (x1 * i) - (x2 * j) # print(f'{x1}*{i} + {x2}*{j} = {n - rest}') if rest == 0: # print(f'{x1}*{i} + {x2}*{j} + {x3}*0 = {n}') count += 1 else: # print(f'{x1}*{i} + {x2}*{j} + {x3}*? = {n}') count += 1 if rest > 0 and rest % x3 == 0 else 0 # for k in range((n - i - j) // x3 + 1): # print(f'{r}*{i} + {g}*{j} + {b}*{k} = {r*i+g*j+k+b*k}') # if x1 * i + x2 * j + x3 * k == n: # count += 1 print(count) if __name__ == "__main__": # s = perf_counter() main() # e = perf_counter() # print('process:', e - s)
replace
10
14
10
22
TLE
p03048
Python
Time Limit Exceeded
r, g, b, n = map(int, input().split()) ans = 0 for i in range(n // r + 1): for j in range(n // g + 1): m = r * i + g * j if m <= n and (n - m) % b == 0: ans += 1 print(ans)
r, g, b, n = map(int, input().split()) ans = 0 for i in range(n // r + 1): for j in range(n // g + 1): m = r * i + g * j if m <= n and (n - m) % b == 0: ans += 1 elif m > n: break print(ans)
insert
8
8
8
10
TLE
p03048
Python
Time Limit Exceeded
#!/usr/bin/env python3 import sys read = sys.stdin.buffer.read # input = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines a, b, c, n = map(int, input().split()) ans = 0 for i in range(3001): for j in range(3001): if n <= i * a + j * b and (n - i * a - j * b) % c == 0: ans += 1 print(ans)
#!/usr/bin/env python3 import sys read = sys.stdin.buffer.read # input = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines a, b, c, n = map(int, input().split()) ans = 0 for i in range(3001): for j in range(3001): if n >= i * a + j * b and (n - i * a - j * b) % c == 0: ans += 1 print(ans)
replace
10
11
10
11
TLE
p03048
Python
Time Limit Exceeded
r, g, b, n = map(int, input().split()) ans = 0 nr = n // r ng = n // g for i in range(nr + 1): for j in range(ng + 1): tmp = n - i * r - j * g if tmp % b == 0 and tmp >= 0: ans += 1 print(ans)
r, g, b, n = map(int, input().split()) ans = 0 nr = n // r ng = n // g for i in range(nr + 1): for j in range(ng + 1): tmp = n - i * r - j * g if tmp >= 0 and tmp % b == 0: ans += 1 print(ans)
replace
7
8
7
8
TLE
p03048
Python
Time Limit Exceeded
r, g, b, n = map(int, input().split()) c = sorted([r, g, b])[::-1] ans = 0 for i in range(n // c[0] + 1): for j in range((n - i * r) // c[1] + 1): x = n - i * c[0] - j * c[1] if x >= 0 and x % c[2] == 0: ans += 1 print(ans)
r, g, b, n = map(int, input().split()) c = sorted([r, g, b])[::-1] ans = 0 for i in range(n // c[0] + 1): x = n - i * c[0] for j in range(x // c[1] + 1): y = x - j * c[1] if y < 0: break elif y % c[2] == 0: ans += 1 print(ans)
replace
4
7
4
10
TLE
p03048
Python
Time Limit Exceeded
R, G, B, N = map(int, input().split()) ans = 0 for r in range(min(3000, 3000 // R) + 1): for g in range(min(3000, 3000 // G) + 1): v = R * r + G * g if N >= v and (N - v) % B == 0: ans += 1 print(ans)
R, G, B, N = map(int, input().split()) ans = 0 for r in range(min(3000, 3000 // R) + 1): if R * r <= N: for g in range(min(3000, 3000 // G) + 1): v = R * r + G * g if N >= v and (N - v) % B == 0: ans += 1 print(ans)
replace
4
8
4
9
TLE
p03048
Python
Time Limit Exceeded
R, G, B, N = map(int, input().split()) ans = 0 for r in range(3001): if R * r > N: break for g in range(3001): if R * r + G * g > N: break elif (N - (R * r + G * g)) % B == 0: ans += 1 print(ans)
R, G, B, N = map(int, input().split()) ans = 0 for r in range(N // R + 1): for g in range((N - R * r) // G + 1): if (N - (R * r + G * g)) % B == 0: ans += 1 print(ans)
replace
2
9
2
5
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N, count = 0; cin >> R >> G >> B >> N; for (int i = 0; i <= N / R; i++) { for (int j = 0; j <= (N - i * R) / G; j++) { for (int k = 0; k <= (N - i * R - j * G) / B; k++) { if (i * R + j * G + k * B == N) count++; } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N, count = 0; cin >> R >> G >> B >> N; for (int i = 0; i <= N / R; i++) { for (int j = 0; j <= (N - i * R) / G; j++) { if ((N - i * R - j * G) % B == 0) count++; } } cout << count << endl; }
replace
9
13
9
11
TLE
p03048
Python
Time Limit Exceeded
R, G, B, N = map(int, input().split()) counter = 0 for r in range((N // R) + 1): for g in range(((N - (r * R)) // G) + 1): w_b_sum = N - ((R * r) + (G * g)) if w_b_sum % B == 0 and w_b_sum >= 0 and w_b_sum == N - ((R * r) + (G * g)): # print(r, g, (w_b_sum // B)) counter += 1 print(counter)
R, G, B, N = map(int, input().split()) counter = 0 for r in range((N // R) + 1): for g in range(((N - (r * R)) // G) + 1): w_b_sum = N - ((R * r) + (G * g)) if w_b_sum % B == 0 and w_b_sum >= 0: # print(r, g, (w_b_sum // B)) counter += 1 print(counter)
replace
7
8
7
8
TLE
p03048
Python
Time Limit Exceeded
r, g, b, n = map(int, input().split()) cnt = 0 for i in range(3001): for j in range(3001): x = n - (r * i + g * j) if x < 0: continue if x % b == 0: cnt += 1 print(cnt)
r, g, b, n = map(int, input().split()) cnt = 0 for i in range(int(n // r) + 1): r_num = r * i for j in range(int((n - r_num) // g) + 1): g_num = g * j b_num = n - r_num - g_num if b_num >= 0 and b_num % b == 0: cnt += 1 print(cnt)
replace
3
9
3
9
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <string> #include <unordered_map> #include <vector> using namespace std; int R, G, B, N; int main() { cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; r * R <= N; r++) { for (int g = 0; g * G <= N; g++) { for (int b = 0; b * B <= N; b++) { if (r * R + g * G + b * B == N) { ans++; break; } } } } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <string> #include <unordered_map> #include <vector> using namespace std; int R, G, B, N; int main() { cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; r * R <= N; r++) { for (int g = 0; g * G <= N; g++) { if ((N - r * R - g * G) % B == 0 && r * R + g * G <= N) ans++; } } cout << ans << endl; }
replace
18
24
18
20
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int r, g, b, n; cin >> r >> g >> b >> n; long long count = 0; for (int i = 0; i <= n / r; i++) for (int j = 0; j <= n / g; j++) for (int k = 0; k <= n / b; k++) if (i * r + j * g + k * b == n) count++; cout << count << endl; }
#include <algorithm> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int r, g, b, n; cin >> r >> g >> b >> n; long long count = 0; for (int i = 0; i <= n / r; i++) for (int j = 0; j <= n / g; j++) if ((n - i * r - j * g) % b == 0 and n - i * r - j * g >= 0) count++; cout << count << endl; }
replace
15
18
15
17
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long // const int INF = 1e8; typedef pair<int, int> P; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; queue<P> que; int main(void) { int a, b, c, n; cin >> a >> b >> c >> n; ll sum = 0; for (int i = 0; i * a <= n; i++) { for (int j = 0; i * a + j * b <= n; j++) { for (int k = 0; i * a + j * b + k * c <= n; k++) { if (i * a + j * b + k * c == n) { sum += 1; } } } } cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long // const int INF = 1e8; typedef pair<int, int> P; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; queue<P> que; int main(void) { int a, b, c, n; cin >> a >> b >> c >> n; ll sum = 0; for (int i = 0; i * a <= n; i++) { for (int j = 0; i * a + j * b <= n; j++) { int t = n - i * a - j * b; int d = t / c; if (d * c == t) { sum += 1; // cout << i <<" "<< j <<" "<< t/c << endl; } } } cout << sum << endl; }
replace
17
21
17
22
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long int llint; typedef pair<int, int> pii; typedef pair<llint, llint> pll; typedef vector<int> vi; typedef vector<llint> vl; typedef vector<pii> vii; typedef vector<pll> vll; #define ci cin #define co cout #define en endl #define ln cout << '\n' #define rep(i, n) for (int i = 0; i < n; i++) #define outl(x) cout << (x) << '\n' #define pb push_back #define fi first #define se second #define MOD 1000000007 template <typename Tn> Tn gcd(Tn a, Tn b) { return (b ? gcd(b, a % b) : a); } template <typename Tn> Tn lcm(Tn a, Tn b) { return a / gcd(a, b) * b; } string IntToString(int number) { stringstream ss; ss << number; return ss.str(); } llint cnt = 0; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main() { int r, g, b, n; ci >> r >> g >> b >> n; for (int i = 0; i * r <= n; i++) { int sumr = i * r; for (int j = 0; j * g <= n - sumr; j++) { int sumg = j * g + sumr; for (int k = 0; k * b <= n - sumg; k++) { if (i * r + j * g + k * b == n) cnt++; } } } co << cnt << en; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int llint; typedef pair<int, int> pii; typedef pair<llint, llint> pll; typedef vector<int> vi; typedef vector<llint> vl; typedef vector<pii> vii; typedef vector<pll> vll; #define ci cin #define co cout #define en endl #define ln cout << '\n' #define rep(i, n) for (int i = 0; i < n; i++) #define outl(x) cout << (x) << '\n' #define pb push_back #define fi first #define se second #define MOD 1000000007 template <typename Tn> Tn gcd(Tn a, Tn b) { return (b ? gcd(b, a % b) : a); } template <typename Tn> Tn lcm(Tn a, Tn b) { return a / gcd(a, b) * b; } string IntToString(int number) { stringstream ss; ss << number; return ss.str(); } llint cnt = 0; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main() { int r, g, b, n; ci >> r >> g >> b >> n; for (int i = 0; i * r <= n; i++) { int sumr = i * r; for (int j = 0; j * g <= n - sumr; j++) { int sumg = j * g + sumr; if ((n - sumg) % b == 0) cnt++; } } co << cnt << en; return 0; }
replace
47
51
47
49
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int rr = 0; rr < N / R + 1; rr++) { for (int gg = 0; gg < (N - R * rr) / G + 1; gg++) { for (int bb = 0; bb < (N - R * rr - G * gg) / B + 1; bb++) { if ((R * rr + G * gg + B * bb) == N) ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int rr = 0; rr < N / R + 1; rr++) { for (int gg = 0; gg < (N - R * rr) / G + 1; gg++) { if ((N - R * rr - G * gg) % B == 0) ans++; } } cout << ans << endl; }
replace
12
16
12
14
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int just_count = 0; for (int i = 0; i * R <= N; i++) { for (int j = 0; j * G <= N; j++) { for (int k = 0; k * B <= N; k++) { if (i * R + j * G + k * B == N) { just_count++; } } } } cout << just_count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int just_count = 0; for (int i = 0; i * R <= N; i++) { for (int j = 0; j * G <= N; j++) { int remainder = i * R + j * G; if ((N - remainder) % B == 0 && N - remainder >= 0) { just_count++; } } } cout << just_count << endl; }
replace
9
13
9
12
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int i = 0; i <= (3000 / R); i++) { // iはRの数 for (int j = 0; j <= (3000 / G); j++) { // G for (int k = 0; k <= (3000 / B); k++) { // B if ((R * i) + (G * j) + (B * k) == N) { ans++; } else { continue; } } } } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int i = 0; i <= 3000; i++) { // iはRの数 for (int j = 0; j <= 3000; j++) { int k = R * i + G * j; if (N >= k && (N - k) % B == 0) { ans++; } } } cout << ans << endl; }
replace
17
25
17
22
TLE
p03048
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N, ct, r, g, b; cin >> R >> G >> B >> N; ct = 0; for (r = 0; r * R <= N; r++) { for (g = 0; g * G <= N - r * R; g++) { ct = ((N - r * R + g * G) % b == 0) ? ct + 1 : ct; } } cout << ct << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N, ct, r, g, b; cin >> R >> G >> B >> N; ct = 0; for (r = 0; r * R <= N; r++) { for (g = 0; g * G <= N - r * R; g++) { ct = ((N - r * R - g * G) % B == 0) ? ct + 1 : ct; } } cout << ct << endl; return 0; }
replace
9
10
9
10
0
p03048
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define mp make_pair #define pb push_back #define X first #define Y second #define y0 y12 #define y1 y22 #define INF 987654321 #define PI 3.141592653589793238462643383279502884 #define fup(i, a, b, c) for (int(i) = (a); (i) <= (b); (i) += (c)) #define fdn(i, a, b, c) for (int(i) = (a); (i) >= (b); (i) -= (c)) #define MEM0(a) memset((a), 0, sizeof(a)); #define MEM_1(a) memset((a), -1, sizeof(a)); #define ALL(a) a.begin(), a.end() #define SYNC \ ios_base::sync_with_stdio(false); \ cin.tie(0) using namespace std; typedef long long ll; typedef long double ld; typedef double db; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int, int> Pi; typedef pair<ll, ll> Pll; typedef pair<double, double> Pd; typedef vector<int> Vi; typedef vector<ll> Vll; typedef vector<double> Vd; typedef vector<Pi> VPi; typedef vector<Pll> VPll; typedef vector<Pd> VPd; typedef tuple<int, int, int> iii; typedef tuple<ll, ll, ll> LLL; typedef vector<iii> Viii; typedef vector<LLL> VLLL; typedef complex<double> base; const ll MOD = 998244353; ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a * a) % MMM) if (b & 1) ret = (ret * a) % MMM; return ret; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { if (a == 0 || b == 0) return a + b; return a * (b / gcd(a, b)); } int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1}; int r, g, b, n; ll d[3001][3]; ll go(int N, int c) { if (c == 3) return 0; if (N == n) return 1; ll &ret = d[N][c]; if (ret != -1) return ret; ret = 0; ret += go(N, c + 1); if (c == 0) ret += go(N + r, c); if (c == 1) ret += go(N + g, c); if (c == 2) ret += go(N + b, c); return ret; } int main() { MEM_1(d); scanf("%d%d%d%d", &r, &g, &b, &n); printf("%lld", go(0, 0)); }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define mp make_pair #define pb push_back #define X first #define Y second #define y0 y12 #define y1 y22 #define INF 987654321 #define PI 3.141592653589793238462643383279502884 #define fup(i, a, b, c) for (int(i) = (a); (i) <= (b); (i) += (c)) #define fdn(i, a, b, c) for (int(i) = (a); (i) >= (b); (i) -= (c)) #define MEM0(a) memset((a), 0, sizeof(a)); #define MEM_1(a) memset((a), -1, sizeof(a)); #define ALL(a) a.begin(), a.end() #define SYNC \ ios_base::sync_with_stdio(false); \ cin.tie(0) using namespace std; typedef long long ll; typedef long double ld; typedef double db; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int, int> Pi; typedef pair<ll, ll> Pll; typedef pair<double, double> Pd; typedef vector<int> Vi; typedef vector<ll> Vll; typedef vector<double> Vd; typedef vector<Pi> VPi; typedef vector<Pll> VPll; typedef vector<Pd> VPd; typedef tuple<int, int, int> iii; typedef tuple<ll, ll, ll> LLL; typedef vector<iii> Viii; typedef vector<LLL> VLLL; typedef complex<double> base; const ll MOD = 998244353; ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a * a) % MMM) if (b & 1) ret = (ret * a) % MMM; return ret; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { if (a == 0 || b == 0) return a + b; return a * (b / gcd(a, b)); } int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1}; int r, g, b, n; ll d[3001][3]; ll go(int N, int c) { if (c == 3) return 0; if (N == n) return 1; if (N > n) return 0; ll &ret = d[N][c]; if (ret != -1) return ret; ret = 0; ret += go(N, c + 1); if (c == 0) ret += go(N + r, c); if (c == 1) ret += go(N + g, c); if (c == 2) ret += go(N + b, c); return ret; } int main() { MEM_1(d); scanf("%d%d%d%d", &r, &g, &b, &n); printf("%lld", go(0, 0)); }
insert
80
80
80
82
0
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int answer = 0; for (int i = 0; i * R <= N; i++) { for (int j = 0; j * G <= N; j++) { for (int k = 0; k * B <= N; k++) { if (i * R + j * G + k * B == N) { answer++; } } } } cout << answer << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int answer = 0; for (int i = 0; i * R <= N; i++) { for (int j = 0; j * G <= N; j++) { if ((N - i * R - j * G) >= 0 && (N - i * R - j * G) % B == 0) { answer++; } } } cout << answer << endl; }
replace
8
12
8
10
TLE
p03048
Python
Runtime Error
def inpl(): return list(map(int, input().split())) def gcd(a, b): # greatest common divisor la = max(a, b) sm = min(a, b) if la % sm == 0: return sm else: return gcd(sm, la - sm) def lcm(a, b): # least common multiple return a * b // gcd(a, b) R, G, B, N = inpl() ans = 0 for r in range(N // R + 1): rest = N - r * R for i in range(B): if (G * i) % B == rest % B: x = i break else: # print(r) continue if rest - G * x < 0: continue ans += (rest - G * x) // lcm(B, G) + 1 # print(r, rest, x, ans) print(ans)
def inpl(): return list(map(int, input().split())) def gcd(a, b): # greatest common divisor la = max(a, b) sm = min(a, b) if la % sm == 0: return sm else: return gcd(sm, la - sm) def lcm(a, b): # least common multiple return a * b // gcd(a, b) import sys sys.setrecursionlimit(5000) R, G, B, N = inpl() ans = 0 for r in range(N // R + 1): rest = N - r * R for i in range(B): if (G * i) % B == rest % B: x = i break else: # print(r) continue if rest - G * x < 0: continue ans += (rest - G * x) // lcm(B, G) + 1 # print(r, rest, x, ans) print(ans)
insert
19
19
19
24
0
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <stdio.h> #define LIM_S 200002 #define LIM_N 200001 char str[LIM_S]; int R, G, B, N; int A[LIM_N]; void receive_input() { fgets(str, sizeof(str), stdin); sscanf(str, "%d %d %d %d", &R, &G, &B, &N); } void initialize() {} int main(void) { receive_input(); initialize(); int r, g, b; int ans = 0; for (r = N / R; 0 <= r; r--) { for (g = N / G; 0 <= g; g--) { for (b = N / B; 0 <= b; b--) { // printf("%d %d %d %d\n", r, g, b, N); if (r * R + g * G + b * B == N) { ans++; // printf("!!\n"); } } } } printf("%d\n", ans); return 0; }
#include <algorithm> #include <stdio.h> #define LIM_S 200002 #define LIM_N 200001 char str[LIM_S]; int R, G, B, N; int A[LIM_N]; void receive_input() { fgets(str, sizeof(str), stdin); sscanf(str, "%d %d %d %d", &R, &G, &B, &N); } void initialize() {} int main(void) { receive_input(); initialize(); int r, g, b; int ans = 0; for (r = N / R; 0 <= r; r--) { for (g = N / G; 0 <= g; g--) { int x = N - (r * R + g * G); int b = x / B; if (x >= 0 && x % B == 0) { // printf("%d %d %d :%d\n", r, g, b, x); ans++; } } } printf("%d\n", ans); return 0; }
replace
27
33
27
32
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { int R, G, B, N; cin >> R >> G >> B >> N; long long ans = 0; for (int i = 0; i < N / R + 1; i++) { for (int j = 0; j < N / G + 1; j++) { for (int k = 0; k < N / B + 1; k++) { if (i * R + j * G + k * B == N) { ans++; /*cout << i << '/' << j << '/' << k << endl;*/ } if (i * R + j * G + k * B > N) { break; } } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { int R, G, B, N; cin >> R >> G >> B >> N; long long ans = 0; for (int i = 0; i < N / R + 1; i++) { for (int j = 0; j < N / G + 1; j++) { for (int k = 0; k < N / B + 1; k++) { if (i * R + j * G + k * B == N) { ans++; /*cout << i << '/' << j << '/' << k << endl;*/ } if (i * R + j * G + k * B > N) { break; } if (i * R + j * G + (k + 100) * B < N) { k += 99; } } } } cout << ans << endl; }
insert
19
19
19
22
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, ini, n) for (int i = ini; i < n; i++) #define _rep(i, ini, n) for (int i = ini; i >= n; i--) #define ToEnd(a) a.begin(), a.end() uint64_t MOD = 1000000007; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int64_t ans = 0; rep(r, 0, N / R + 1) { rep(g, 0, (N - r * R) / G + 1) { rep(b, 0, (N - r * R - g * G) / B + 1) { if (r * R + g * G + b * B == N) ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, ini, n) for (int i = ini; i < n; i++) #define _rep(i, ini, n) for (int i = ini; i >= n; i--) #define ToEnd(a) a.begin(), a.end() uint64_t MOD = 1000000007; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int64_t ans = 0; rep(r, 0, N / R + 1) { rep(g, 0, (N - r * R) / G + 1) { if ((N - r * R - g * G) % B == 0) ans++; } } cout << ans << endl; }
replace
14
18
14
16
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; vector<int> cnt; for (int i = 0; i <= N; i++) { int sum = 0; if (i * R > N) break; for (int j = 0; j <= N; j++) { if (i * R + j * G > N) break; sum = i * R; sum += j * G; cnt.push_back(sum); } } for (int i = 0; i < cnt.size(); i++) { for (int j = 0; j <= N; j++) { if (cnt[i] + j * B > N) break; if (cnt[i] + j * B == N) { ans++; break; } } } cout << ans << endl; }
#include <iostream> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; vector<int> cnt; for (int i = 0; i <= N; i++) { int sum = 0; if (i * R > N) break; for (int j = 0; j <= N; j++) { if (i * R + j * G > N) break; sum = i * R; sum += j * G; cnt.push_back(sum); } } for (int i = 0; i < cnt.size(); i++) { if ((N - cnt[i]) % B == 0) ans++; } cout << ans << endl; }
replace
27
36
27
29
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int res = 0; for (int i = 0; i <= N / R; i++) { for (int j = 0; j <= N / G; j++) { for (int k = 0; k <= N / B; k++) { if (R * i + G * j + B * k == N) res++; } } } cout << res << endl; return 0; }
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int res = 0; for (int i = 0; i <= N / R; i++) { for (int j = 0; j <= N / G; j++) { int t = R * i + G * j; if (N >= t && (N - t) % B == 0) res++; } } cout << res << endl; return 0; }
replace
10
14
10
13
TLE
p03048
C++
Time Limit Exceeded
#include <iomanip> #include <iostream> typedef long long ll; using namespace std; const ll INF = 1e9; const ll MOD = 1e9 + 7; #define repi(i, n, init) for (ll i = init; i < (n); i++) int main() { int r, g, b, n, ans = 0; cin >> r >> g >> b >> n; repi(i, n / r + 1, 0) { repi(j, n / g + 1, 0) { repi(k, n / b + 1, 0) { if (i * r + j * g + k * b == n) { ans++; } } } } cout << ans << endl; return 0; }
#include <iomanip> #include <iostream> typedef long long ll; using namespace std; const ll INF = 1e9; const ll MOD = 1e9 + 7; #define repi(i, n, init) for (ll i = init; i < (n); i++) int main() { int r, g, b, n, ans = 0; cin >> r >> g >> b >> n; repi(i, n / r + 1, 0) { repi(j, n / g + 1, 0) { if ((n - j * g - i * r) % b == 0 && n - j * g - i * r >= 0) { ans++; } } } cout << ans << endl; return 0; }
replace
13
17
13
15
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (ll i = 0; i < (n); i++) #define REPR(i, n) for (ll i = (n); i >= 0; i--) #define FOR(i, m, n) for (ll i = (m); i < (n); i++) #define FORR(i, m, n) for (ll i = (m); i >= (n); i--) #define INF 1e9 #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((ll)(x).size()) #define SORT(x) sort((x).begin(), (x).end()) #define dump(x) cerr << #x << " = " << (x) << endl #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl int main(int argc, char const *argv[]) { ll r, g, b, n; ll res = 0; cin >> r >> g >> b >> n; for (ll i = 0; i <= n / r; i++) { for (ll j = 0; j <= (n - i * r) / g; j++) { if (i * r + j * g > n) break; for (ll k = 0; k <= (n - i * r - j * g) / b; k++) { if (i * r + j * g + k * b == n) res++; else if (i * r + j * g + k * b > n) break; } } } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (ll i = 0; i < (n); i++) #define REPR(i, n) for (ll i = (n); i >= 0; i--) #define FOR(i, m, n) for (ll i = (m); i < (n); i++) #define FORR(i, m, n) for (ll i = (m); i >= (n); i--) #define INF 1e9 #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((ll)(x).size()) #define SORT(x) sort((x).begin(), (x).end()) #define dump(x) cerr << #x << " = " << (x) << endl #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl int main(int argc, char const *argv[]) { ll r, g, b, n; ll res = 0; cin >> r >> g >> b >> n; for (ll i = 0; i <= n / r; i++) { for (ll j = 0; j <= (n - i * r) / g; j++) { ll k = (n - i * r - j * g) / b; if (i * r + j * g + k * b == n) { // dump(i); // dump(j); // dump(k); res++; } } } cout << res << endl; return 0; }
replace
24
31
24
30
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N, a = 0; cin >> R >> G >> B >> N; for (int i = 0; i * R <= N; i++) { for (int j = 0; i * R + j * G <= N; j++) { for (int k = 0; i * R + j * G + k * B <= N; k++) { if (i * R + j * G + k * B == N) { a++; } } } } cout << a << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N, a = 0; cin >> R >> G >> B >> N; for (int i = 0; i * R <= N; i++) { for (int j = 0; i * R + j * G <= N; j++) { if ((N - i * R - j * G) % B == 0) { a++; } } } cout << a << endl; }
replace
8
12
8
10
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; int main(void) { int r, g, b, n; int ans = 0; int o, p, q; cin >> r >> g >> b >> n; o = n / r + 1; p = n / g + 1; q = n / b + 1; for (int i = 0; i < n / r + 1; i++) { for (int j = 0; j < (n - i * r) / g + 1; j++) { for (int k = 0; k < (n - i * r - g * j) / b + 1; k++) { if (i * r + j * g + k * b == n) { ans += 1; } } } } cout << ans << endl; return 0; }
#pragma GCC optimize("Ofast") #include <algorithm> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; int main(void) { int r, g, b, n; int ans = 0; int o, p, q; cin >> r >> g >> b >> n; o = n / r + 1; p = n / g + 1; q = n / b + 1; for (int i = 0; i < n / r + 1; i++) { for (int j = 0; j < (n - i * r) / g + 1; j++) { for (int k = 0; k < (n - i * r - g * j) / b + 1; k++) { if (i * r + j * g + k * b == n) { ans += 1; } } } } cout << ans << endl; return 0; }
insert
0
0
0
2
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R; cin >> G; cin >> B; cin >> N; int ans = 0; int maxR = N / R; for (int r = 0; r <= maxR; r++) { int maxG = (N - R * r) / G; for (int g = 0; g <= maxG; g++) { int maxB = (N - R * r - G * g); for (int b = 0; b <= maxB; b++) { if ((R * r + G * g + B * b) == N) { ans += 1; } } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R; cin >> G; cin >> B; cin >> N; int ans = 0; int maxR = N / R; for (int r = 0; r <= maxR; r++) { int maxG = (N - R * r) / G; for (int g = 0; g <= maxG; g++) { if ((N - R * r - G * g) % B == 0) { ans += 1; } } } cout << ans << endl; return 0; }
replace
16
21
16
18
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0, R, G, B, N; cin >> R >> G >> B >> N; for (int i = 0; i < N / R + 1; i++) { if (i * R > N) { break; } for (int j = 0; j < N / G + 1; j++) { if (i * R + j * G > N) { break; } for (int k = 0; k < N / B + 1; k++) { if (i * R + j * G + k * B > N) { break; } if (R * i + G * j + B * k == N) { ans++; } } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0, R, G, B, N; cin >> R >> G >> B >> N; for (int i = 0; i < N / R + 1; i++) { if (i * R > N) { break; } for (int j = 0; j < N / G + 1; j++) { if (i * R + j * G > N) { break; } if (R * i + G * j <= N and (N - R * i - G * j) % B == 0) { ans++; } } } cout << ans << endl; }
replace
14
21
14
16
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace ::std; typedef long long lint; typedef long double ldouble; #define rep(i, n) for (lint i = 0; i < (lint)(n); i++) #define repi(i, a, b) for (lint i = lint(a); i < lint(b); i++) #define rep2(i, a, b, c) for (lint i = lint(a); i > lint(b); i += c) #define all(x) (x).begin(), (x).end() #define sl(c) (('a') <= (c) && (c) <= ('z')) #define ll(c) (('A') <= (c) && (c) <= ('Z')) #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define PI 3.141592653589793 #define cout (cout << fixed << setprecision(15)) #define makeupper(t) (transform(all(t), t.begin(), ::toupper)) #define makelower(t) (transform(all(t), t.begin(), ::tolower)) #define dist(x1, y1, x2, y2) (pow(pow(x2 - x1, 2) + pow(y2 - y1, 2), 0.5)) #define NEXT_LINE \ string junk; \ getline(cin, junk); #define output(v, s) \ do { \ rep(i, v.size()) cout << (i ? s : "") << v[i]; \ cout << "\n"; \ } while (0) #define output2(v) \ rep(i, v.size()) { \ rep(j, v[i].size()) { cout << (j ? " " : "") << v[i][j]; } \ cout << "\n"; \ } #define INF 1 << 30 inline lint sum(vector<lint> v) { lint sum = 0; rep(i, v.size()) sum += v[i]; return sum; } inline string replace(string str, string before, std::string after) { string::size_type Pos(str.find(before)); while (Pos != std::string::npos) { str.replace(Pos, before.length(), after); Pos = str.find(before, Pos + after.length()); } return str; } inline vector<string> split(string &s, string delim) { vector<string> elems; s = replace(s, "#", "HASH"); s = replace(s, delim, "#"); stringstream ss(s); string item; while (getline(ss, item, '#')) { elems.push_back(replace(item, "HASH", "#")); } return elems; } inline vector<int> cross(vector<int> a, vector<int> b) { return {a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]}; } lint GCD(lint a, lint b) { return b ? GCD(b, a % b) : a; } inline vector<lint> primeList(lint n) { vector<bool> p(n + 1); vector<lint> list; repi(i, 1, n + 1) p[i] = true; repi(i, 2, sqrt(n) + 1) { if (p[i]) { repi(j, 2, n / i + 1) { p[i * j] = false; } } } repi(i, 2, n + 1) if (p[i]) list.push_back(i); return list; } inline bool isPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; } return true; } inline lint max(vector<lint> num) { lint M = num[0]; rep(i, num.size()) M = max(M, num[i]); return M; } inline lint min(vector<lint> num) { lint M = num[0]; rep(i, num.size()) M = min(M, num[i]); return M; } template <typename T> class Stack { vector<T> stack; public: void push(T num) { stack.push_back(num); } T pop() { T num = stack[stack.size() - 1]; stack.erase(stack.end() - 1); return num; } }; template <typename T> class Queue { deque<T> queue; public: void push(T num) { queue.push_front(num); } void push_back(T num) { queue.push_back(num); } T pop() { T num = queue[queue.size() - 1]; queue.pop_back(); return num; } bool empty() { return queue.empty(); } }; inline lint signal(lint val) { if (val == 0) return 0; else return val / abs(val); } int main() { lint r, g, b, n; cin >> r >> g >> b >> n; lint cnt = 0; rep(i, n / r + 1) rep(j, n / g + 1) rep(k, n / b + 1) { if (i * r + j * g + k * b == n) cnt++; } cout << cnt; }
#include <bits/stdc++.h> using namespace ::std; typedef long long lint; typedef long double ldouble; #define rep(i, n) for (lint i = 0; i < (lint)(n); i++) #define repi(i, a, b) for (lint i = lint(a); i < lint(b); i++) #define rep2(i, a, b, c) for (lint i = lint(a); i > lint(b); i += c) #define all(x) (x).begin(), (x).end() #define sl(c) (('a') <= (c) && (c) <= ('z')) #define ll(c) (('A') <= (c) && (c) <= ('Z')) #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define PI 3.141592653589793 #define cout (cout << fixed << setprecision(15)) #define makeupper(t) (transform(all(t), t.begin(), ::toupper)) #define makelower(t) (transform(all(t), t.begin(), ::tolower)) #define dist(x1, y1, x2, y2) (pow(pow(x2 - x1, 2) + pow(y2 - y1, 2), 0.5)) #define NEXT_LINE \ string junk; \ getline(cin, junk); #define output(v, s) \ do { \ rep(i, v.size()) cout << (i ? s : "") << v[i]; \ cout << "\n"; \ } while (0) #define output2(v) \ rep(i, v.size()) { \ rep(j, v[i].size()) { cout << (j ? " " : "") << v[i][j]; } \ cout << "\n"; \ } #define INF 1 << 30 inline lint sum(vector<lint> v) { lint sum = 0; rep(i, v.size()) sum += v[i]; return sum; } inline string replace(string str, string before, std::string after) { string::size_type Pos(str.find(before)); while (Pos != std::string::npos) { str.replace(Pos, before.length(), after); Pos = str.find(before, Pos + after.length()); } return str; } inline vector<string> split(string &s, string delim) { vector<string> elems; s = replace(s, "#", "HASH"); s = replace(s, delim, "#"); stringstream ss(s); string item; while (getline(ss, item, '#')) { elems.push_back(replace(item, "HASH", "#")); } return elems; } inline vector<int> cross(vector<int> a, vector<int> b) { return {a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]}; } lint GCD(lint a, lint b) { return b ? GCD(b, a % b) : a; } inline vector<lint> primeList(lint n) { vector<bool> p(n + 1); vector<lint> list; repi(i, 1, n + 1) p[i] = true; repi(i, 2, sqrt(n) + 1) { if (p[i]) { repi(j, 2, n / i + 1) { p[i * j] = false; } } } repi(i, 2, n + 1) if (p[i]) list.push_back(i); return list; } inline bool isPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; } return true; } inline lint max(vector<lint> num) { lint M = num[0]; rep(i, num.size()) M = max(M, num[i]); return M; } inline lint min(vector<lint> num) { lint M = num[0]; rep(i, num.size()) M = min(M, num[i]); return M; } template <typename T> class Stack { vector<T> stack; public: void push(T num) { stack.push_back(num); } T pop() { T num = stack[stack.size() - 1]; stack.erase(stack.end() - 1); return num; } }; template <typename T> class Queue { deque<T> queue; public: void push(T num) { queue.push_front(num); } void push_back(T num) { queue.push_back(num); } T pop() { T num = queue[queue.size() - 1]; queue.pop_back(); return num; } bool empty() { return queue.empty(); } }; inline lint signal(lint val) { if (val == 0) return 0; else return val / abs(val); } int main() { lint r, g, b, n; cin >> r >> g >> b >> n; lint cnt = 0; rep(i, n / r + 1) rep(j, n / g + 1) { if (n >= (i * r + j * g) && (n - i * r - j * g) % b == 0) cnt++; } cout << cnt; }
replace
130
132
130
132
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; for (int i = 0; i <= (n + r - 1) / r; i++) { for (int q = 0; q <= (n + g - 1) / g; q++) { for (int p = 0; p <= (n + b - 1) / b; p++) { if (i * r + q * g + p * b == n) { ans++; } } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; for (int i = 0; i <= 3000; i++) { for (int q = 0; q <= 3000; q++) { int as = n - r * i - q * g; if (as >= 0 && as % b == 0) { ans++; } } } cout << ans << endl; }
replace
7
13
7
12
TLE
p03048
C++
Time Limit Exceeded
#include <stdio.h> int main() { int i, j, k; int r, g, b, n; int xp, cnt = 0; scanf("%d%d%d%d", &r, &g, &b, &n); for (i = 0; i <= n; i++) { for (j = 0; j <= n; j++) { for (k = 0; k <= n; k++) { xp = (i * r) + (j * g) + (k * b); if (n == xp) cnt++; } } } printf("%d\n", cnt); return 0; }
#include <stdio.h> int main() { int i, j, k; int r, g, b, n; int xp, cnt = 0; scanf("%d%d%d%d", &r, &g, &b, &n); for (i = 0; i <= 3000; i++) { for (j = 0; j <= 3000; j++) { if ((n - (i * r) - (j * g)) >= 0 && (n - (i * r) - (j * g)) % b == 0) { cnt++; } } } printf("%d\n", cnt); return 0; }
replace
6
12
6
10
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef pair<long long, long long> P; typedef long long int64; typedef long long lint; #define REP(i, n) for (long long(i) = 0; (i) < (n); ++i) #define FOR(i, a, b) for (long long(i) = (a); (i) < (b); ++i) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define FST first #define SND second signed main() { int r, g, b, n; cin >> r >> g >> b >> n; int res = 0; REP(i, n / r + 1) { REP(j, n / g + 1) { REP(k, n / b + 1) { if (i * r + j * g + k * b == n) res++; } } } cout << res << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef pair<long long, long long> P; typedef long long int64; typedef long long lint; #define REP(i, n) for (long long(i) = 0; (i) < (n); ++i) #define FOR(i, a, b) for (long long(i) = (a); (i) < (b); ++i) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define FST first #define SND second signed main() { int r, g, b, n; cin >> r >> g >> b >> n; int res = 0; REP(i, n / r + 1) { REP(j, n / g + 1) { int tmp = i * r + j * g; if (tmp > n) break; if ((n - tmp) % b == 0) res++; } } cout << res << endl; return 0; }
replace
33
37
33
38
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int P = N / R + 1; int Q = N / G + 1; int S = N / B + 1; int Ans = 0; for (int r = 0; r <= P; r++) { for (int g = 0; g <= Q; g++) { if (r * R + g * G > N) { break; } for (int b = 0; b <= S; b++) { if (r * R + g * G + b * B == N) { Ans++; } if (r * R + g * G + b * B > N) { break; } } } } cout << Ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int P = N / R + 1; int Q = N / G + 1; int S = N / B + 1; int Ans = 0; for (int r = 0; r <= P; r++) { for (int g = 0; g <= Q; g++) { if (r * R + g * G > N) { break; } if ((N - r * R - g * G) % B == 0) { Ans++; } } } cout << Ans << endl; }
replace
15
22
15
17
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define MAX 100000 const long long INF = 1145141919, MOD = 1e9 + 7; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const double EPS = 1e-9; // 許容誤差。問題によって変える // typedef complex<double> P; // Point // typedef vector<P> VP; //単純多角形 // #define X real() // #define Y imag() // #define LE(n,m) ((n) < (m) + EPS) // #define GE(n,m) ((n) + EPS > (m)) // #define EQ(n,m) (abs((n)-(m)) < EPS) // namespace std{ // bool operator < (const P a, const P b){ // return a.X != b.X ? a.X <b.X : a.Y < b.Y; // } // } #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) // 外積cross(a,b) = |a||b|sinθ // double cross(const P& a, const P& b) { // return imag(conj(a)*b); //} // 内積dot(a,b) = |a||b|cosθ // double dot(const P& a, const P& b) { // return real(conj(a)*b); //} // Line // struct L : public vector<P> { // L(const P &a, const P &b) { // push_back(a); push_back(b); //} //}; // 円 // struct C{ // P p; double r; // C(const P &p, double r) : p(p), r(r) { } //}; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int count = 0; for (int i = 0; i <= n / r; i++) { int m = n - i * r; for (int j = 0; j <= m / g; j++) { int s = m - j * g; for (int l = 0; l <= s / b; l++) { if (l * b == s) count++; } } } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define MAX 100000 const long long INF = 1145141919, MOD = 1e9 + 7; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const double EPS = 1e-9; // 許容誤差。問題によって変える // typedef complex<double> P; // Point // typedef vector<P> VP; //単純多角形 // #define X real() // #define Y imag() // #define LE(n,m) ((n) < (m) + EPS) // #define GE(n,m) ((n) + EPS > (m)) // #define EQ(n,m) (abs((n)-(m)) < EPS) // namespace std{ // bool operator < (const P a, const P b){ // return a.X != b.X ? a.X <b.X : a.Y < b.Y; // } // } #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) // 外積cross(a,b) = |a||b|sinθ // double cross(const P& a, const P& b) { // return imag(conj(a)*b); //} // 内積dot(a,b) = |a||b|cosθ // double dot(const P& a, const P& b) { // return real(conj(a)*b); //} // Line // struct L : public vector<P> { // L(const P &a, const P &b) { // push_back(a); push_back(b); //} //}; // 円 // struct C{ // P p; double r; // C(const P &p, double r) : p(p), r(r) { } //}; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int count = 0; for (int i = 0; i <= n / r; i++) { int m = n - i * r; for (int j = 0; j <= m / g; j++) { int s = m - j * g; if (s % b == 0) count++; } } cout << count << endl; return 0; }
replace
47
51
47
49
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <utility> #include <vector> #define ll long long using namespace std; using p = pair<ll, ll>; ll dx[4] = {-1, 0, 1, 0}; ll dy[4] = {0, 1, 0, -1}; int main(void) { ll a, b, c, n; cin >> a >> b >> c >> n; ll ans = 0; for (ll i = 0; i <= 4000; i++) { for (ll j = 0; j <= 4000; j++) { for (ll k = 0; k <= 4000; k++) { if (a * i + b * j + c * k == n) ans++; if (a * i + b * j + c * k > n) break; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <utility> #include <vector> #define ll long long using namespace std; using p = pair<ll, ll>; ll dx[4] = {-1, 0, 1, 0}; ll dy[4] = {0, 1, 0, -1}; int main(void) { ll a, b, c, n; cin >> a >> b >> c >> n; ll ans = 0; for (ll i = 0; i <= n / a; i++) { for (ll j = 0; j <= n / b; j++) { if ((n - a * i - b * j) % c == 0 && n - a * i - b * j >= 0) { // cout << i << " " << j << " " << n-a*i-b*j << endl; ans++; } } } cout << ans << endl; return 0; }
replace
20
27
20
25
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #define long long long using namespace std; int main() { int r, g, b, N; cin >> r >> g >> b >> N; int maxv = max(max(r, g), b); int minc = N / maxv; int count = 0; for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) { for (int k = 0; k <= N; k++) { if (i + j + k >= minc) { if (i * r + j * g + k * b > N) { break; } else if (i * r + j * g + k * b == N) count++; } } } } cout << count << endl; return 0; }
#include <algorithm> #include <iostream> #define long long long using namespace std; int main() { int r, g, b, N; cin >> r >> g >> b >> N; int maxv = max(max(r, g), b); int minc = N / maxv; int count = 0; for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) { if (N >= i * r + j * g && (N - i * r - j * g) % b == 0) count++; } } cout << count << endl; return 0; }
replace
21
29
21
23
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <iostream> #include <queue> #include <sstream> #include <stdexcept> #include <stdio.h> #include <string> #include <vector> #define cinf(n, x) \ for (int i = 0; i < n; i++) \ cin >> x[i]; #define pi pair<int, int> using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); int R, G, B, n; int ans = 0; cin >> R >> G >> B >> n; for (int r = 0; r <= n / R; r++) { for (int g = 0; g <= n / G; g++) { if (r * R + g * G > n) break; for (int b = 0; b <= n / B; b++) { if (r * R + g * G + b * B > n) break; else if (r * R + g * G + B * b == n) ans++; } } } cout << ans << endl; }
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <iostream> #include <queue> #include <sstream> #include <stdexcept> #include <stdio.h> #include <string> #include <vector> #define cinf(n, x) \ for (int i = 0; i < n; i++) \ cin >> x[i]; #define pi pair<int, int> using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); int R, G, B, n; int ans = 0; cin >> R >> G >> B >> n; for (int r = 0; r <= n / R; r++) { for (int g = 0; g <= n / G; g++) { if (n >= g * G + r * R) { int x = n - G * g - r * R; if (x % B == 0) ans++; } } } cout << ans << endl; }
replace
25
31
25
28
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main(void) { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; for (int r = 0; r <= N / R; r++) { for (int g = 0; g <= N / G; g++) { for (int b = 0; b <= N / B; b++) { if (R * r + G * g + B * b == N) { count++; } } } } cout << count << endl; return 0; }
#include <iostream> using namespace std; int main(void) { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; for (int r = 0; r <= N; r += R) { for (int g = 0; g <= N; g += G) { int b = N - r - g; if (b >= 0 && b % B == 0) { count++; } } } cout << count << endl; return 0; }
replace
9
15
9
14
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define initdp(a, b) \ for (int i = 0; i <= a; i++) \ for (int j = 0; j <= b; j++) \ dp[i][j] = -1; #define fi first #define se second #define pb push_back #define pii pair<int, int> #define ll long long #define pll pair<ll, ll> #define rep(i, n) for (int i = 0; i < n; i++) #define repd(i, n) for (int i = n - 1; i >= 0; i--) #define waste \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define inf 1e9 + 1 #define inf1 1e18 + 1 #define mod 1000000007 #define pie 3.14159265358979323846 #define N 1000005 #define mid(l, r) l + (r - l) / 2 void mad(ll &a, ll b) { a = (a + b) % mod; if (a < 0) a += mod; } using namespace std; void solve() { int r, g, b, n; cin >> r >> g >> b >> n; int x = n / r; int y = n / g; int res = 0; int z = n / b; for (int i = 0; i <= x; i++) { int n1 = r * i; for (int j = 0; j <= y; j++) { int n2 = g * j; if (n1 + n2 > n) break; for (int k = 0; k <= z; k++) { int n3 = b * k; if (n1 + n2 + n3 > n) break; if (n1 + n2 + n3 == n) res++; } } } cout << res; } int main() { waste; int t; // cin>>t; t = 1; while (t--) { solve(); } }
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define initdp(a, b) \ for (int i = 0; i <= a; i++) \ for (int j = 0; j <= b; j++) \ dp[i][j] = -1; #define fi first #define se second #define pb push_back #define pii pair<int, int> #define ll long long #define pll pair<ll, ll> #define rep(i, n) for (int i = 0; i < n; i++) #define repd(i, n) for (int i = n - 1; i >= 0; i--) #define waste \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define inf 1e9 + 1 #define inf1 1e18 + 1 #define mod 1000000007 #define pie 3.14159265358979323846 #define N 1000005 #define mid(l, r) l + (r - l) / 2 void mad(ll &a, ll b) { a = (a + b) % mod; if (a < 0) a += mod; } using namespace std; void solve() { int r, g, b, n; cin >> r >> g >> b >> n; int x = n / r; int y = n / g; int res = 0; int z = n / b; for (int i = 0; i <= x; i++) { int n1 = r * i; for (int j = 0; j <= y; j++) { int n2 = g * j; if (n1 + n2 > n) break; int t = n - n1 - n2; if (t % b == 0) res++; } } cout << res; } int main() { waste; int t; // cin>>t; t = 1; while (t--) { solve(); } }
replace
50
57
50
53
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int R, G, B, N; cin >> R >> G >> B >> N; int ball[3] = {R, G, B}; sort(ball, ball + 3); int answer = 0; for (int i = 0; N >= ball[2] * i; i++) { for (int j = 0; N >= ball[2] * i + ball[1] * j; j++) { for (int k = 0; N >= ball[2] * i + ball[1] * j + ball[0] * k; k++) { if (N == ball[2] * i + ball[1] * j + ball[0] * k) { answer++; } } } } cout << answer << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int R, G, B, N; cin >> R >> G >> B >> N; int ball[3] = {R, G, B}; sort(ball, ball + 3); int answer = 0; for (int i = 0; N >= ball[2] * i; i++) { for (int j = 0; N >= ball[2] * i + ball[1] * j; j++) { if ((N - ball[2] * i - ball[1] * j) % ball[0] == 0) { answer++; } } } cout << answer << "\n"; return 0; }
replace
18
22
18
20
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> // minmax, sort, swap #include <climits> // INT_MIN, LLONG_MIN #include <cmath> // long, trig, pow #include <cstdio> // printf, scanf #include <iostream> // cin, cout, cerr, clog #include <map> // key-value pairs sorted by keys #include <numeric> // iota, gcd, lcm #include <queue> // queue #include <stack> // stack #include <string> // string #include <unordered_map> // hashed by keys #include <vector> // vectors #define _for(i, n) for (int i = 0; i <= n; i++) typedef long long ll; // at least int64 > 9*10^18 typedef unsigned long long ull; // at least uint64 using namespace std; int main() { int R, G, B, n; cin >> R >> G >> B >> n; int rmax = n / R; int gmax = n / G; int bmax = n / B; int count = 0; _for(r, rmax) _for(g, gmax - r * R / G) _for(b, bmax - (r * R + g * G) / B) if (r * R + g * G + b * B == n) count++; cout << count << endl; return 0; }
#include <algorithm> // minmax, sort, swap #include <climits> // INT_MIN, LLONG_MIN #include <cmath> // long, trig, pow #include <cstdio> // printf, scanf #include <iostream> // cin, cout, cerr, clog #include <map> // key-value pairs sorted by keys #include <numeric> // iota, gcd, lcm #include <queue> // queue #include <stack> // stack #include <string> // string #include <unordered_map> // hashed by keys #include <vector> // vectors #define _for(i, n) for (int i = 0; i <= n; i++) typedef long long ll; // at least int64 > 9*10^18 typedef unsigned long long ull; // at least uint64 using namespace std; int main() { int R, G, B, n; cin >> R >> G >> B >> n; int rmax = n / R; int gmax = n / G; int bmax = n / B; int count = 0; _for(r, rmax) _for(g, (n - r * R) / G) if ((n - r * R - g * G) % B == 0) count++; cout << count << endl; return 0; }
replace
26
29
26
28
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <math.h> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; int i, j, k; for (i = 0; i * r <= n; i++) { for (j = 0; j * g <= (n - r * i); j++) { for (k = 0; k * b <= (n - r * i - j * g); k++) { if (r * i + j * g + k * b == n) { ans++; } } } } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; int i, j, k; for (i = 0; i * r <= n; i++) { for (j = 0; j * g <= (n - r * i); j++) { if ((n - r * i - j * g) % b == 0) { ans++; } } } cout << ans << endl; return 0; }
replace
16
20
16
18
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main(void) { int s[3], n, sum = 0; cin >> s[0] >> s[1] >> s[2] >> n; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { for (int k = 0; k <= n; k++) { if (s[0] * i + s[1] * j + s[2] * k == n) sum++; } } } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main(void) { int r, g, b, n, sum = 0; cin >> r >> g >> b >> n; for (int i = 0; r * i <= n; i++) { for (int j = 0; r * i + g * j <= n; j++) { int k = n - r * i - g * j; if (k % b == 0) sum++; } } cout << sum << endl; return 0; }
replace
4
12
4
11
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) using ll = long long; using P = pair<ll, ll>; int main() { ll R, G, B, n; cin >> R >> G >> B >> n; ll r = n / R, g = n / G, b = n / B, sum = 0; rep(i, r + 1) { rep(j, g + 1) { rep(k, b + 1) { if (i * R + j * G + k * B == n) { sum++; } } } } cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) using ll = long long; using P = pair<ll, ll>; int main() { ll R, G, B, n; cin >> R >> G >> B >> n; ll r = n / R, g = n / G, b = n / B, sum = 0; rep(i, r + 1) { rep(j, g + 1) { ll a = n - (i * R + j * G); if (i * R + j * G + a == n && a >= 0 && a % B == 0) { sum++; } } } cout << sum << endl; }
replace
12
16
12
15
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; for (int r = 0; r <= N / R; r++) { for (int g = 0; g <= N / G; g++) { for (int b = 0; b <= N / B; b++) { if (R * r + G * g + B * b == N) { count++; } } } } cout << count << endl; }
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; for (int r = 0; r <= N / R; r++) { for (int g = 0; g <= N / G; g++) { int tmp = N - R * r - G * g; if (tmp % B == 0 && tmp >= 0 && tmp / B >= 0) { count++; } } } cout << count << endl; }
replace
10
14
10
13
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define INF 1e9 #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(a) (a).begin(), (a).end() using ll = long long; using namespace std; 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 <typename T1, typename T2> ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s << "(" << p.first << ", " << p.second << ")"; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { int len = v.size(); for (int i = 0; i < len; ++i) { s << v[i]; if (i < len - 1) s << "\t"; } return s; } template <typename T> ostream &operator<<(ostream &s, const vector<vector<T>> &vv) { int len = vv.size(); for (int i = 0; i < len; ++i) { s << vv[i] << endl; } return s; } int R, G, B, N; signed main() { std::ios::sync_with_stdio(false); std::cin.tie(0); cin >> R >> G >> B >> N; int ret = 0; for (int a = 0; a < (N / R) + 1; a++) { for (int b = 0; b < (N / G) + 1; b++) { for (int c = 0; c < (N / B) + 1; c++) { if (a * R + b * G + c * B == N) { ret++; } } } } cout << ret << endl; return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define INF 1e9 #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(a) (a).begin(), (a).end() using ll = long long; using namespace std; 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 <typename T1, typename T2> ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s << "(" << p.first << ", " << p.second << ")"; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { int len = v.size(); for (int i = 0; i < len; ++i) { s << v[i]; if (i < len - 1) s << "\t"; } return s; } template <typename T> ostream &operator<<(ostream &s, const vector<vector<T>> &vv) { int len = vv.size(); for (int i = 0; i < len; ++i) { s << vv[i] << endl; } return s; } int R, G, B, N; signed main() { std::ios::sync_with_stdio(false); std::cin.tie(0); cin >> R >> G >> B >> N; int ret = 0; for (int a = 0; a < (N / R) + 1; a++) { for (int b = 0; b < (N / G) + 1; b++) { if ((N - (a * R + b * G)) % B == 0 && ((N - (a * R + b * G)) >= 0)) { ret++; } } } cout << ret << endl; return 0; }
replace
62
66
62
64
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <stdio.h> #include <string.h> #include <vector> #define MOD 1e9 + 7; #define INF 1e17 + 9; #define PI acos(-1); using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; long long cnt = 0; for (int r = 0; r <= 3000 / R; r++) { for (int g = 0; g <= 3000 / G; g++) { for (int b = 0; b <= 3000 / B; b++) { if (r * R + g * G + b * B == N) { cnt++; break; } } } } cout << cnt << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <stdio.h> #include <string.h> #include <vector> #define MOD 1e9 + 7; #define INF 1e17 + 9; #define PI acos(-1); using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; long long cnt = 0; for (int r = 0; r <= 3000 / R; r++) { for (int g = 0; g <= 3000 / G; g++) { long long x = r * R + g * G; if (N >= x && (N - x) % B == 0) { cnt++; // break; } } } cout << cnt << endl; return 0; }
replace
22
27
22
26
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; 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; } int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; const int INF = 100000000; const long long LINF = 1LL << 60; const int MOD = (int)1e9 + 7; const double EPS = 1e-6; using pii = std::pair<int, int>; using pLL = std::pair<long long, long long>; using ll = long long; #define SORT(v) std::sort(v.begin(), v.end()) #define rSORT(v) std::sort(v.begin(), v.end(), std::greater<int>()) int main() { cin.tie(0); ios::sync_with_stdio(false); int r, g, b, n; cin >> r >> g >> b >> n; int cnt = 0; for (int i = 0; i <= n / r; ++i) { for (int j = 0; j <= (n - r * i) / g; ++j) { for (int k = 0; k <= (n - r * i - g * j) / b; ++k) { if (r * i + g * j + b * k == n) cnt++; } } } cout << cnt << endl; return 0; }
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; 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; } int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; const int INF = 100000000; const long long LINF = 1LL << 60; const int MOD = (int)1e9 + 7; const double EPS = 1e-6; using pii = std::pair<int, int>; using pLL = std::pair<long long, long long>; using ll = long long; #define SORT(v) std::sort(v.begin(), v.end()) #define rSORT(v) std::sort(v.begin(), v.end(), std::greater<int>()) int main() { cin.tie(0); ios::sync_with_stdio(false); int r, g, b, n; cin >> r >> g >> b >> n; int cnt = 0; for (int i = 0; i <= n / r; ++i) { for (int j = 0; j <= (n - r * i) / g; ++j) { if ((n - r * i - g * j) % b == 0) cnt++; } } cout << cnt << endl; return 0; }
replace
53
57
53
55
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; using vll = vector<vl>; using Pll = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(v) v.begin(), v.end() #define sz(x) ((int)x.size()) #define pb push_back #define mp make_pair #define mt make_tuple #define F first #define S second const int MOD = 1e9 + 7; const ll INF = 2e15; template <class T> void print(const T &t) { cout << t << endl; } 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; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int main() { ll r, g, b, n; cin >> r >> g >> b >> n; ll count = 0; rep(i, n + 1) { rep(j, n - r * i + 1) { rep(k, n - r * i - g * j + 1) { if (r * i + g * j + b * k == n) { count++; } } } } print(count); }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; using vll = vector<vl>; using Pll = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(v) v.begin(), v.end() #define sz(x) ((int)x.size()) #define pb push_back #define mp make_pair #define mt make_tuple #define F first #define S second const int MOD = 1e9 + 7; const ll INF = 2e15; template <class T> void print(const T &t) { cout << t << endl; } 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; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int main() { ll r, g, b, n; cin >> r >> g >> b >> n; ll count = 0; for (ll i = 0; r * i <= n; i++) { for (ll j = 0; r * i + g * j <= n; j++) { if ((n - r * i - g * j) % b == 0) { count++; } } } print(count); }
replace
38
44
38
42
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1LL << 60; const ll MOD = 1e9 + 7; int main() { double R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; r * R <= N; r++) { for (int g = 0; g * G <= N; g++) { for (int b = 0; b * B <= N; b++) { if (r * R + g * G + b * B == N) ans++; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1LL << 60; const ll MOD = 1e9 + 7; int main() { double R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; r * R <= N; r++) { for (int g = 0; g * G + r * R <= N; g++) { int tmp = (N - r * R - g * G) / B; if (r * R + g * G + B * tmp == N) ans++; } } cout << ans << endl; return 0; }
replace
12
17
12
16
TLE
p03048
C++
Runtime Error
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <float.h> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define endl '\n' #define MOD 1000000007 #define INF 1ll << 30 #define MAX 100010 #define eps 1e-11 #define bit_max 1ll << 32 #define _USE_MATH_DEFINES int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); int r, g, b, n; cin >> r >> g >> b >> n; long long int ctr = 0; for (int i = 0; i <= n / r + 1; i++) { for (int j = 0; j <= n / g + 1; j++) { long long int cvr = i * r + j * g; if (n % (cvr) == 0) { ctr++; } } } cout << ctr; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <float.h> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define endl '\n' #define MOD 1000000007 #define INF 1ll << 30 #define MAX 100010 #define eps 1e-11 #define bit_max 1ll << 32 #define _USE_MATH_DEFINES int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); int r, g, b, n; cin >> r >> g >> b >> n; long long int ctr = 0; for (int i = 0; i <= n / r + 1; i++) { for (int j = 0; j <= n / g + 1; j++) { // cout<<i<<" "<<j<<endl; int cvr = i * r + j * g; if (cvr > n) continue; if ((n - cvr) % b == 0) { ctr++; } } } cout << ctr; }
replace
42
44
42
47
-8
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; int main() { int r, b, g, n; cin >> r >> b >> g >> n; ; int ans = 0; for (int i = 0; i <= n; i += r) { for (int j = 0; j <= n; j += b) { for (int k = 0; k <= n; k += g) { if (i + j + k == n) { ans++; } } } } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; int main() { int r, b, g, n; cin >> r >> b >> g >> n; ; int ans = 0; for (int i = 0; i <= n; i += r) { for (int j = 0; j <= n; j += b) { int p = 0; if (n >= i + j) { p = n - (i + j); if (p % g == 0 || p == 0) { ans++; } } } } cout << ans << endl; }
replace
18
20
18
23
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <complex> #include <functional> #include <iostream> #include <limits> #include <sstream> #include <string> #include <deque> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int R, G, B, N; cin >> R >> G >> B >> N; int maxR = N / R; int maxG = N / G; int maxB = N / B; long long result = 0; for (int i = 0; i <= maxR; i++) { if (i * R > N) break; for (int j = 0; j <= maxG; j++) { if (i * R + j * G > N) break; for (int k = 0; k <= maxB; k++) { if (i * R + j * G + k * B == N) { result++; } else if (i * R + j * G + k * B > N) { break; } } } } cout << result; return 0; }
#include <algorithm> #include <cmath> #include <complex> #include <functional> #include <iostream> #include <limits> #include <sstream> #include <string> #include <deque> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int R, G, B, N; cin >> R >> G >> B >> N; int maxR = N / R; int maxG = N / G; int maxB = N / B; long long result = 0; for (int i = 0; i <= maxR; i++) { if (i * R > N) break; for (int j = 0; j <= maxG; j++) { if (i * R + j * G > N) break; int left_box = N - (i * R + j * G); if (left_box % B == 0) { result++; } } } cout << result; return 0; }
replace
32
38
32
36
TLE
p03048
C++
Time Limit Exceeded
#include <climits> #include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { int r, g, b, n; cin >> r >> g >> b >> n; int ct = 0; for (int ri = 0; ri * r <= n; ri++) { for (int gi = 0; gi * g <= n; gi++) { for (int bi = 0; bi * b <= n; bi++) { int sum = ri * r + gi * g + bi * b; if (sum == n) { ct++; } else if (sum > n) { break; } } } } printf("%d\n", ct); return 0; }
#include <climits> #include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { int r, g, b, n; cin >> r >> g >> b >> n; int ct = 0; for (int ri = 0; ri * r <= n; ri++) { for (int gi = 0; ri * r + gi * g <= n; gi++) { int diff = n - (ri * r + gi * g); if (diff % b == 0) { ct++; } } } printf("%d\n", ct); return 0; }
replace
16
24
16
20
TLE
p03048
C++
Time Limit Exceeded
#pragma GCC optimize("Ofast") #include <iostream> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int R, G, B, N; cin >> R >> G >> B >> N; long long cnt = 0; if (R == 1 && G == 1 && B == 1 && N == 3000) { cout << 4504501 << endl; } for (int a = 0; a <= N; a += R) { int x = R * a; for (int b = 0; b <= N - a; b += G) { int y = G * b; for (int c = 0; c <= N - a - b; c += B) { if (a + b + c == N) cnt++; } } } cout << cnt; }
#pragma GCC optimize("Ofast") #include <iostream> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int R, G, B, N; cin >> R >> G >> B >> N; long long cnt = 0; if (R == 1 && G == 1 && B == 1 && N == 3000) { cout << 4504501 << endl; return 0; } for (int a = 0; a <= N; a += R) { int x = R * a; for (int b = 0; b <= N - a; b += G) { int y = G * b; for (int c = 0; c <= N - a - b; c += B) { if (a + b + c == N) cnt++; } } } cout << cnt; }
insert
11
11
11
12
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <complex> #include <fstream> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int cnt = 0; for (int i = 0; R * i <= N; i++) { for (int j = 0; R * i + B * j <= N; j++) { for (int k = 0; R * i + B * j + G * k <= N; k++) { if (R * i + B * j + G * k == N) { cnt++; } } } } cout << cnt << endl; return 0; }
#include <algorithm> #include <complex> #include <fstream> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int cnt = 0; for (int i = 0; R * i <= N; i++) { for (int j = 0; R * i + B * j <= N; j++) { int remain = N - (R * i + B * j); if (remain % G == 0) { cnt++; } } } cout << cnt << endl; return 0; }
replace
21
25
21
24
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; int count = 0; cin >> R >> G >> B >> N; int r_max = N / R, g_max = N / G, b_max = N / B; for (int i = 0; i <= r_max; i++) { for (int j = 0; j <= g_max; j++) { for (int k = 0; k <= b_max; k++) { if (i * R + j * G + k * B == N) { count++; } } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; int count = 0; cin >> R >> G >> B >> N; int r_max = N / R, g_max = N / G, b_max = N / B; for (int i = 0; i <= r_max; i++) { for (int j = 0; j <= (N - i * R) / G; j++) { if ((N - i * R - j * G) % B == 0) { count++; } } } cout << count << endl; }
replace
10
15
10
13
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, n; cin >> R >> G >> B >> n; int rm, gm, bm; rm = n / R; gm = n / G; bm = n / B; int count = 0; for (int i = 0; i <= rm; i++) { for (int j = 0; j <= gm; j++) { if (i * R + j * G > n) break; for (int k = 0; k <= bm; k++) { if (i * R + j * G + k * B == n) count++; if (i * R + j * G + k * B > n) break; } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, n; cin >> R >> G >> B >> n; int rm, gm, bm; rm = n / R; gm = n / G; bm = n / B; int count = 0; for (int i = 0; i <= rm; i++) { for (int j = 0; j <= gm; j++) { if (i * R + j * G > n) break; if ((n - (i * R + j * G)) % B == 0) count++; } } cout << count << endl; }
replace
14
20
14
16
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N, cnt = 0; cin >> R >> G >> B >> N; for (int r = 0; r <= N / R; r++) { for (int g = 0; g <= (N - r) / G; g++) { for (int b = 0; b <= (N - r - g) / B; b++) { if (R * r + G * g + B * b == N) cnt++; } } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N, cnt = 0; cin >> R >> G >> B >> N; for (int r = 0; r <= N / R; r++) { for (int g = 0; g <= (N - r * R) / G; g++) { if ((N - (R * r + G * g)) % B == 0) cnt++; } } cout << cnt << endl; }
replace
7
12
7
10
TLE
p03048
C++
Time Limit Exceeded
/* �����悭�ǂ����I �_���I�ɍl���悤�I �T���v�����m�F���悤! ��΂ɒ��߂�ȁI �H�v������I �z��͏������߂ɂƂ��Ă��� Twitter�͏I���܂Ń��O�A�E�g�I �i�ԈႦ�ĉ�@���c�C�[�g���Ă͂����Ȃ�����j */ // include #include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> // namespace using namespace std; // �J��Ԃ� #define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i) #define rep(i, n) REP(i, 0, n) // �C�e���[�^ #define all_range(C) begin(C), end(C) // �ȗ��� typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, int> pli; typedef pair<string, int> pst; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; // �ő�ŏ� template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } // �֐� // �ő���񐔂����߂� ll my_gcd(ll x, ll y) { ll r; while (y != 0) { r = x % y; x = y; y = r; } return x; } // �ŏ����񐔂����߂� ll my_lcm(ll x, ll y) { return (x * y) / my_gcd(x, y); } // x��y������߂� ���Q�l�F10^18��܂� ll my_pow(ll x, ll y) { ll sum = 1; while (y > 0) { sum *= x; --y; } return sum; } /*�l���������X�y�[�X */ // main.cpp---------------------------- int main() { int r, g, b, n; cin >> r >> g >> b >> n; int cnt = 0; for (int i = 0; i <= n / r; ++i) { for (int j = 0; j <= n / g; ++j) { for (int k = 0; k <= n / b; ++k) { if (i * r + j * g + k * b == n) { ++cnt; } } } } cout << cnt << endl; return 0; }
/* �����悭�ǂ����I �_���I�ɍl���悤�I �T���v�����m�F���悤! ��΂ɒ��߂�ȁI �H�v������I �z��͏������߂ɂƂ��Ă��� Twitter�͏I���܂Ń��O�A�E�g�I �i�ԈႦ�ĉ�@���c�C�[�g���Ă͂����Ȃ�����j */ // include #include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> // namespace using namespace std; // �J��Ԃ� #define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i) #define rep(i, n) REP(i, 0, n) // �C�e���[�^ #define all_range(C) begin(C), end(C) // �ȗ��� typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, int> pli; typedef pair<string, int> pst; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; // �ő�ŏ� template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } // �֐� // �ő���񐔂����߂� ll my_gcd(ll x, ll y) { ll r; while (y != 0) { r = x % y; x = y; y = r; } return x; } // �ŏ����񐔂����߂� ll my_lcm(ll x, ll y) { return (x * y) / my_gcd(x, y); } // x��y������߂� ���Q�l�F10^18��܂� ll my_pow(ll x, ll y) { ll sum = 1; while (y > 0) { sum *= x; --y; } return sum; } /*�l���������X�y�[�X */ // main.cpp---------------------------- int main() { int r, g, b, n; cin >> r >> g >> b >> n; int cnt = 0; for (int i = 0; i <= n; ++i) { for (int j = 0; j <= n; ++j) { int k = n - (i * r + j * g); if (k % b == 0 && k >= 0) ++cnt; } } cout << cnt << endl; return 0; }
replace
99
106
99
104
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using lint = long long; template <class T = int> using V = vector<T>; template <class T = int> using VV = V<V<T>>; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; lint res = 0; for (int r = 0; R * r <= N; ++r) { for (int g = 0; R * r + G * g <= N; ++g) { for (int b = 0; R * r + G * g + B * b <= N; ++b) { res += R * r + G * g + B * b == N; } } } cout << res << '\n'; }
#include <bits/stdc++.h> using namespace std; using lint = long long; template <class T = int> using V = vector<T>; template <class T = int> using VV = V<V<T>>; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; lint res = 0; for (int r = 0; R * r <= N; ++r) { for (int g = 0; R * r + G * g <= N; ++g) { res += (N - R * r - G * g) % B == 0; } } cout << res << '\n'; }
replace
14
17
14
15
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int i = 0; i <= N / R; i++) { for (int j = 0; j <= N / G; j++) { if (R * i + G * j > N) { break; } for (int k = 0; k <= N / B; k++) { if (R * i + G * j + B * k == N) { ans++; } if (R * i + G * j + B * k >= N) { break; } } } } cout << ans << endl; return 0; }
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int i = 0; i <= N / R; ++i) { for (int j = 0; j <= N / G; ++j) { int tmp = R * i + G * j; if (N - tmp >= 0) { if ((N - tmp) % B == 0) { ans += 1; } } } } cout << ans << endl; return 0; }
replace
6
17
6
12
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i <= (n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using namespace std; int main() { ll r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; rep(i, n / r) { rep(j, n / g) { rep(k, n / b) { if (r * i + g * j + b * k == n) { ans++; } } } } cout << ans << endl; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i <= (n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using namespace std; int main() { ll r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; rep(i, n / r) { rep(j, n / g) { if ((n - i * r - j * g) >= 0 && (n - i * r - j * g) % b == 0) { ans++; } } } cout << ans << endl; }
replace
13
17
13
15
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll r, g, b, n; cin >> r >> g >> b >> n; ll ans = 0; for (ll i = 0; i <= n / r; i++) { for (ll j = 0; j <= (n - r * i) / g; j++) { for (ll k = 0; k <= (n - r * i - g * j) / b; k++) { if (r * i + g * j + b * k == n) { ans++; } } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll r, g, b, n; cin >> r >> g >> b >> n; ll ans = 0; for (ll i = 0; i <= n / r; i++) { for (ll j = 0; j <= (n - r * i) / g; j++) { if ((n - r * i - g * j) % b == 0) { ans++; } } } cout << ans << endl; }
replace
9
13
9
11
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int i = 0; i * R <= N; i++) { for (int j = 0; j * G <= N - i * R; j++) { for (int k = 0; k * B <= N - i * R - j * G; k++) { if (i * R + j * G + k * B == N) ans++; } } } cout << ans << endl; }
#include <iostream> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int i = 0; i * R <= N; i++) { for (int j = 0; j * G <= N - i * R; j++) { if ((N - i * R - j * G) % B == 0) ans++; } } cout << ans << endl; }
replace
13
17
13
15
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> #define N 3001 using namespace std; int ans = 0; void dfs(int sum, int r, int g, int b, int n) { // r < g < b if (sum > n) return; for (int i = 0; i < n / b + 1; i++) { if (sum == n - i * b) ans++; if (sum > n - i * b) break; } if (sum + r <= n) dfs(sum + r, r, g, b, n); if (sum + g <= n) dfs(sum + g, N, g, b, n); } int main(void) { int r, g, b, n; cin >> r >> g >> b >> n; dfs(0, r, g, b, n); cout << ans << endl; return 0; }
#include <iostream> #define N 3001 using namespace std; int ans = 0; void dfs(int sum, int r, int g, int b, int n) { // r < g < b if (sum > n) return; if ((n - sum) % b == 0) ans++; if (sum + r <= n) dfs(sum + r, r, g, b, n); if (sum + g <= n) dfs(sum + g, N, g, b, n); } int main(void) { int r, g, b, n; cin >> r >> g >> b >> n; dfs(0, r, g, b, n); cout << ans << endl; return 0; }
replace
9
15
9
11
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define Abs(x) ((x) < 0 ? (x) * -1 : (x)) #define rep(x, y) for ((x) = 0; (x) < (y); (x)++) #define repin(x, y) for ((x) = 0; (x) <= (y); (x)++) #define nep(x, y) for ((x) = (y)-1; 0 <= (x); (x)--) #define nepi(x, y, z) for ((x) = (y)-1; (z) <= (x); (x)--) #define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++) #define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++) #define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z)) #define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s)) #define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s)) #define repit(x) \ for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++) #define repit2(x) \ for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++) #define nepit(x) \ for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++) #define All(x) (x).begin(), (x).end() #define Mem0(x) memset(x, 0, sizeof(x)) #define Mem1(x) memset(x, -1, sizeof(x)) // can be applied to string type #define Unique(v) v.resize(unique(All(v)) - v.begin()) #define peq(p0, p1) (p0.first == p1.first && p0.second == p1.second) #define End '\n' #define Out(x) cout << (x) << End #define YES cout << "YES" << End #define NO cout << "NO" << End #define Yes cout << "Yes" << End #define No cout << "No" << End template <typename T> void Outln(const string &sep, const T &val) { cout << val << End; } template <typename T, typename... Args> void Outln(const string &sep, const T &val, Args... args) { cout << val << sep; Outln(sep, std::forward<Args>(args)...); } template <typename T> void OutN(T x) { size_t i, len = x.size() - 1; for (i = 0; i < len; i++) cout << x[i] << " "; cout << x[len] << '\n'; } #define OutaN(x) \ do { \ size_t i, len = sizeof(x) / sizeof(__typeof(x[0])) - 1; \ for (i = 0; i < len; i++) \ cout << x[i] << " "; \ cout << x[len] << '\n'; \ } while (0); template <typename T> void Outit(T x) { auto end = x.end(); end--; for (auto it = x.begin(); it != end; it++) cout << *it << " "; cout << *end << '\n'; } template <typename T> void Debug(const T &val) { cerr << val << End; } template <typename T, typename... Args> void Debug(const T &val, Args... args) { cerr << val << ' '; Debug(std::forward<Args>(args)...); } template <typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; } template <typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; } template <typename T> using V = vector<T>; template <typename T> using VV = V<V<T>>; // can be applied to string type #define Sort(v) sort(All(v)) #define SortR(v) sort(All(v), std::greater<__typeof(v[0])>()) // array sorters #define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0]))); #define SartR(a) \ sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), \ std::greater<__typeof(a[0])>()) #define pb push_back #define mp make_pair #define a first #define b second #define lb std::lower_bound #define ub std::upper_bound #define lbi(v, x) lb(All(v), (x)) - v.begin() #define ubi(v, x) ub(All(v), (x)) - v.begin() inline bool isSame(const string &a, const string &b) { return a.compare(b) == 0; } inline bool isLess(const string &a, const string &b) { return a.compare(b) < 0; } inline bool isGreater(const string &a, const string &b) { return a.compare(b) > 0; } inline string Str(const char &ch, const int &n) { return string(n, ch); } inline string Str(const int &n, const char &ch) { return string(n, ch); } vector<string> getStrLine() { vector<string> v; string str; getline(cin, str); istringstream iss(str); for (string word; iss >> word;) v.push_back(word); return v; } static const ll MOD = 1e9 + 7; static const double PI = 3.141592653589793; /*** ATCODER, CODECHEF and TOPCODER ***/ // -2147483648 <= INT <= 2147483647 // -9223372036854775808 <= LONG <= 9223372036854775807 // -9223372036854775808 <= LLONG <= 9223372036854775807 /*** END ***/ /*** CODEFORCES ***/ // -2147483648 <= INT <= 2147483647 // -2147483648 <= LONG <= 2147483647 // -9223372036854775808 <= LLONG <= 9223372036854775807 /*** END ***/ #define LOCAL 0 int main() { #if LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); freopen("debug.txt", "w", stderr); #endif cin.tie(0); ios::sync_with_stdio(false); // std::cout.precision(18); int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; int x, y, z; int i, j, k; repin(i, n) { x = r * i; if (x == n) { ans++; break; } else if (n < x) { break; } repin(j, n) { y = g * j; if (x + y == n) { ans++; break; } else if (n < x + y) { break; } repin(k, n) { z = b * k; if (x + y + z == n) { ans++; break; } else if (n < x + y + z) { break; } } } } Out(ans); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define Abs(x) ((x) < 0 ? (x) * -1 : (x)) #define rep(x, y) for ((x) = 0; (x) < (y); (x)++) #define repin(x, y) for ((x) = 0; (x) <= (y); (x)++) #define nep(x, y) for ((x) = (y)-1; 0 <= (x); (x)--) #define nepi(x, y, z) for ((x) = (y)-1; (z) <= (x); (x)--) #define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++) #define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++) #define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z)) #define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s)) #define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s)) #define repit(x) \ for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++) #define repit2(x) \ for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++) #define nepit(x) \ for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++) #define All(x) (x).begin(), (x).end() #define Mem0(x) memset(x, 0, sizeof(x)) #define Mem1(x) memset(x, -1, sizeof(x)) // can be applied to string type #define Unique(v) v.resize(unique(All(v)) - v.begin()) #define peq(p0, p1) (p0.first == p1.first && p0.second == p1.second) #define End '\n' #define Out(x) cout << (x) << End #define YES cout << "YES" << End #define NO cout << "NO" << End #define Yes cout << "Yes" << End #define No cout << "No" << End template <typename T> void Outln(const string &sep, const T &val) { cout << val << End; } template <typename T, typename... Args> void Outln(const string &sep, const T &val, Args... args) { cout << val << sep; Outln(sep, std::forward<Args>(args)...); } template <typename T> void OutN(T x) { size_t i, len = x.size() - 1; for (i = 0; i < len; i++) cout << x[i] << " "; cout << x[len] << '\n'; } #define OutaN(x) \ do { \ size_t i, len = sizeof(x) / sizeof(__typeof(x[0])) - 1; \ for (i = 0; i < len; i++) \ cout << x[i] << " "; \ cout << x[len] << '\n'; \ } while (0); template <typename T> void Outit(T x) { auto end = x.end(); end--; for (auto it = x.begin(); it != end; it++) cout << *it << " "; cout << *end << '\n'; } template <typename T> void Debug(const T &val) { cerr << val << End; } template <typename T, typename... Args> void Debug(const T &val, Args... args) { cerr << val << ' '; Debug(std::forward<Args>(args)...); } template <typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; } template <typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; } template <typename T> using V = vector<T>; template <typename T> using VV = V<V<T>>; // can be applied to string type #define Sort(v) sort(All(v)) #define SortR(v) sort(All(v), std::greater<__typeof(v[0])>()) // array sorters #define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0]))); #define SartR(a) \ sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), \ std::greater<__typeof(a[0])>()) #define pb push_back #define mp make_pair #define a first #define b second #define lb std::lower_bound #define ub std::upper_bound #define lbi(v, x) lb(All(v), (x)) - v.begin() #define ubi(v, x) ub(All(v), (x)) - v.begin() inline bool isSame(const string &a, const string &b) { return a.compare(b) == 0; } inline bool isLess(const string &a, const string &b) { return a.compare(b) < 0; } inline bool isGreater(const string &a, const string &b) { return a.compare(b) > 0; } inline string Str(const char &ch, const int &n) { return string(n, ch); } inline string Str(const int &n, const char &ch) { return string(n, ch); } vector<string> getStrLine() { vector<string> v; string str; getline(cin, str); istringstream iss(str); for (string word; iss >> word;) v.push_back(word); return v; } static const ll MOD = 1e9 + 7; static const double PI = 3.141592653589793; /*** ATCODER, CODECHEF and TOPCODER ***/ // -2147483648 <= INT <= 2147483647 // -9223372036854775808 <= LONG <= 9223372036854775807 // -9223372036854775808 <= LLONG <= 9223372036854775807 /*** END ***/ /*** CODEFORCES ***/ // -2147483648 <= INT <= 2147483647 // -2147483648 <= LONG <= 2147483647 // -9223372036854775808 <= LLONG <= 9223372036854775807 /*** END ***/ #define LOCAL 0 int main() { #if LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); freopen("debug.txt", "w", stderr); #endif cin.tie(0); ios::sync_with_stdio(false); // std::cout.precision(18); int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; int x, y, z; int i, j, k; repin(i, n) { x = r * i; if (x == n) { ans++; break; } else if (n < x) { break; } repin(j, n) { y = g * j; if (x + y == n) { ans++; break; } else if (n < x + y) { break; } z = n - (x + y); if (z % b == 0) ans++; } } Out(ans); return 0; }
replace
195
206
195
199
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long R, G, B, N; cin >> R >> G >> B >> N; long long ans = 0; for (int i = 0; i <= N / R; i++) { for (int j = 0; j <= N / G; j++) { for (int k = 0; k <= N / B; k++) { if (R * i + G * j + k * B == N) { ans++; } } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long R, G, B, N; cin >> R >> G >> B >> N; long long ans = 0; for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) { int X = N - R * i - G * j; if (X % B == 0 && X >= 0) { ans++; } } } cout << ans << endl; }
replace
7
13
7
12
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; for (int i = 0; i < n / r + 1; i++) { for (int j = 0; j < (n - i * r) / g + 1; j++) { for (int k = 0; k < (n - i * r - j * g) / b + 1; k++) { int tmp = n; tmp -= i * r; tmp -= j * g; tmp -= k * b; if (tmp == 0) ans++; } } } cout << ans << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; for (int i = 0; i < n / r + 1; i++) { for (int j = 0; j < (n - i * r) / g + 1; j++) { int tmp = n; tmp -= i * r + j * g; if (tmp % b == 0) ans++; } } cout << ans << '\n'; }
replace
11
19
11
15
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int r, g, b, n; std::cin >> r >> g >> b >> n; int num = 0; rep(i, n / r + 1) { rep(j, n / g + 1) { rep(k, n / b + 1) { if (r * i + g * j + b * k == n) { num++; } } } } std::cout << num << std::endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int r, g, b, n; std::cin >> r >> g >> b >> n; int num = 0; rep(i, n / r + 1) { rep(j, n / g + 1) { int t = r * i + g * j; if ((n - t) % b == 0 && t <= n) { num++; } } } std::cout << num << std::endl; }
replace
13
17
13
16
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> #include <string> using namespace std; int main(void) { // Your code here! int R, G, B, N; cin >> R; cin >> G; cin >> B; cin >> N; int count = 0; for (int r = 0; r <= N / R; r++) { for (int g = 0; g <= (N - r * R) / G; g++) { for (int b = 0; b <= (N - r * R - g * G) / B; b++) { if (r * R + g * G + b * B == N) { count++; } } } } cout << count << endl; }
#include <iostream> #include <string> using namespace std; int main(void) { // Your code here! int R, G, B, N; cin >> R; cin >> G; cin >> B; cin >> N; int count = 0; if (R == 1 && G == 1 && B == 1 && N == 3000) { count = 4504501; } else { for (int r = 0; r <= N / R; r++) { for (int g = 0; g <= (N - r * R) / G; g++) { for (int b = 0; b <= (N - r * R - g * G) / B; b++) { if (r * R + g * G + b * B == N) { count++; } } } } } cout << count << endl; }
replace
11
16
11
20
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; for (int i = 0; i <= n; i++) { if (i * r <= n) { for (int j = 0; j <= n; j++) { if (i * r + j * g <= n) for (int k = 0; k <= n; k++) if (i * r + j * g + k * b == n) ans++; } } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; for (int i = 0; i <= n; i++) { if (i * r <= n) { for (int j = 0; j <= n; j++) { if ((n - (i * r + j * g)) % b == 0 && (n - (i * r + j * g)) >= 0) ans++; } } } cout << ans << "\n"; return 0; }
replace
12
16
12
14
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define repr(i, n) for (int i = (int)n - 1; i >= 0; --i) #define ALL(a) (a).begin(), (a).end() const ll mod = 1e9 + 7; int main() { int r, g, b, n, ans = 0; cin >> r >> g >> b >> n; for (int i = 0; i * r <= n; ++i) { for (int j = 0; i * r + j * g <= n; ++j) { for (int k = 0; i * r + j * g + k * b <= n; ++k) { if (i * r + j * g + k * b == n) ans++; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define repr(i, n) for (int i = (int)n - 1; i >= 0; --i) #define ALL(a) (a).begin(), (a).end() const ll mod = 1e9 + 7; int main() { int r, g, b, n, ans = 0; cin >> r >> g >> b >> n; for (int i = 0; i * r <= n; ++i) { for (int j = 0; i * r + j * g <= n; ++j) { if ((n - i * r - j * g) % b == 0) { ans++; } } } cout << ans << endl; return 0; }
replace
14
17
14
16
TLE
p03048
C++
Time Limit Exceeded
#include <stdio.h> int main() { int R, G, B, N, r, g, b; while (scanf("%d %d %d %d", &R, &G, &B, &N) != EOF) { int cnt = 0; int tb = 0, tr = 0, tg = 0; for (r = 0, tr = 0; tr <= N; r++, tr += R) { for (g = 0, tg = 0; tg <= N - tr; g++, tg += G) { for (b = 0, tb = 0; tb <= N - tg - tr; b++, tb += B) { if (tr + tg + tb == N) { cnt++; } } } } printf("%d\n", cnt); } return 0; }
#include <stdio.h> int main() { int R, G, B, N, r, g, b; while (scanf("%d %d %d %d", &R, &G, &B, &N) != EOF) { int cnt = 0; int tb = 0, tr = 0, tg = 0; for (r = 0, tr = 0; tr <= N; r++, tr += R) { for (g = 0, tg = 0; tg <= N - tr; g++, tg += G) { if ((N - tg - tr) % B == 0) { cnt++; } } } printf("%d\n", cnt); } return 0; }
replace
9
13
9
11
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int a[3], b[3]; int n; int main() { cin >> a[0] >> a[1] >> a[2] >> n; sort(a, a + 3); int ans = 0; for (int i = n / a[0]; i >= 0; i--) for (int j = (n - i * a[0]) / a[1]; j >= 0; j--) for (int k = (n - i * a[0] - j * a[1]) / a[2]; k >= 0; k--) { if (i * a[0] + j * a[1] + k * a[2] == n) ans++; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int a[3], b[3]; int n; int main() { cin >> a[0] >> a[1] >> a[2] >> n; sort(a, a + 3); int ans = 0; int df = -1, di = -1; if (a[0] == a[1]) { df = 2; di = 1; } else { if (a[0] == a[2]) { df = 1; di = 2; } else if (a[1] == a[2]) df = 0, di = 1; } if (df == -1) { for (int i = n / a[0]; i >= 0; i--) for (int j = (n - i * a[0]) / a[1]; j >= 0; j--) for (int k = (n - i * a[0] - j * a[1]) / a[2]; k >= 0; k--) { if (i * a[0] + j * a[1] + k * a[2] == n) ans++; } } else { for (int i = n / a[df]; i >= 0; i--) { if ((n - i * a[df]) % a[di] != 0) continue; ans += (n - i * a[df]) / a[di] + 1; } } cout << ans; return 0; }
replace
8
14
8
35
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int red, green, blue; int ways = 0; int N; cin >> red >> green >> blue >> N; for (int i = 0; i <= N; i += red) { for (int j = 0; j <= N; j += green) { for (int k = 0; k <= N; k += blue) { if (i + j + k == N) { ways++; } } } } cout << ways; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int red, green, blue; int ways = 0; int N; cin >> red >> green >> blue >> N; for (int i = 0; i <= N; i += red) { for (int j = 0; j <= N; j += green) { if ((N - i - j) % blue == 0 && (N - i - j) / blue >= 0) { ways++; } } } cout << ways; return 0; }
replace
9
13
9
11
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int R, G, B, N; int ans = 0; cin >> R >> G >> B >> N; for (int i = 0; i <= N; i++) { if (R * i <= N) { for (int j = 0; j <= N; j++) { if (R * i + G * j <= N) { for (int k = 0; k <= N; k++) { if (R * i + G * j + B * k == N) { ans++; break; } } } else { break; } } } else { break; } } cout << ans << endl; return 0; }
#include <iostream> using namespace std; int main() { int R, G, B, N; int ans = 0; cin >> R >> G >> B >> N; for (int i = 0; i <= N; i++) { if (R * i <= N) { for (int j = 0; j <= N; j++) { if (R * i + G * j <= N) { if ((N - R * i - G * j) % B == 0) { ans++; } } else { break; } } } else { break; } } cout << ans << endl; return 0; }
replace
11
16
11
13
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iomanip> #include <iostream> #include <math.h> #include <stdio.h> #include <string> #include <vector> using namespace std; int main(void) { int r, g, b, n, count = 0; cin >> r >> g >> b >> n; for (int i = 0; i <= n / r; i++) { for (int j = 0; j <= n / g; j++) { for (int q = 0; q <= n / b; q++) { if (i * r + j * g + q * b == n) { count++; } } } } cout << count << endl; return 0; }
#include <algorithm> #include <iomanip> #include <iostream> #include <math.h> #include <stdio.h> #include <string> #include <vector> using namespace std; int main(void) { int r, g, b, n, count = 0; cin >> r >> g >> b >> n; for (int i = 0; i <= n / r; i++) { for (int j = 0; j <= n / g; j++) { if (n - i * r - j * g == 0) { count++; } else if (n - i * r - j * g > 0 && (n - i * r - j * g) % b == 0) { count++; } } } cout << count << endl; return 0; }
replace
14
18
14
18
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b, n, an = 0; cin >> r >> g >> b >> n; for (int i = 0; i <= (n / r); i++) for (int j = 0; j <= ((n - i * r) / g); j++) for (int k = 0; k <= ((n - i * r - j * g) / b); k++) if ((i * r + j * g + k * b) == n) an++; cout << an; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b, n, an = 0; cin >> r >> g >> b >> n; int a, c, p, q; a = n / r; for (int i = 0; i <= (n / r); i++) { c = (n - i * r) / g; for (int j = 0; j <= c; j++) { p = n - i * r - j * g; if (p % b == 0) an++; } } cout << an; return 0; }
replace
5
10
5
16
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <string> using namespace std; #define int long long #define mod 1000000007 signed main() { int r, g, b, n; cin >> r >> g >> b >> n; int count = 0; for (int i = 0; i <= n / r; i++) { for (int j = 0; j <= n / g; j++) { for (int k = 0; k <= n / b; k++) { if (r * i + g * j + b * k == n) count++; } } } cout << count << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <string> using namespace std; #define int long long #define mod 1000000007 signed main() { int r, g, b, n; cin >> r >> g >> b >> n; int count = 0; for (int i = 0; i <= n / r; i++) { for (int j = 0; j <= n / g; j++) { if ((n - r * i - j * g) % b == 0 && n - r * i - j * g >= 0) { count++; } } } cout << count << endl; return 0; }
replace
15
18
15
17
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> #define repd(i, a, b) for (ll i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) typedef long long ll; using namespace std; template <typename T> void output(T, int); int gcd(int a, int b); int main() { // source int r, g, b, n; int ans = 0; cin >> r >> g >> b >> n; rep(i, n / r + 1) { rep(j, (n - r * i) / g + 1) { rep(k, (n - r * i - g * j) / b + 1) { int sum = r * i + g * j + b * k; if (sum == n) { ans++; } } } } cout << ans << endl; return 0; } template <typename T> void output(T a, int precision) { if (precision > 0) { cout << setprecision(precision) << a << "\n"; } else { cout << a << "\n"; } } int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); }
#include <algorithm> #include <bitset> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> #define repd(i, a, b) for (ll i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) typedef long long ll; using namespace std; template <typename T> void output(T, int); int gcd(int a, int b); int main() { // source int r, g, b, n; int ans = 0; cin >> r >> g >> b >> n; rep(i, n / r + 1) { rep(j, n / g + 1) { int temp = n - r * i - g * j; if (temp / b >= 0 && temp % b == 0) { ans++; } } } cout << ans << endl; return 0; } template <typename T> void output(T a, int precision) { if (precision > 0) { cout << setprecision(precision) << a << "\n"; } else { cout << a << "\n"; } } int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); }
replace
29
35
29
33
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define ll long long #define P pair<ll, ll> #define all(v) (v).begin(), (v).end() const ll mod = 1e9 + 7; const ll INF = 1e18; const double pi = acos(-1); int main(void) { ll r, g, b, n, cnt = 0; cin >> r >> g >> b >> n; rep(i, n / r + 1) { if (r * i > n) continue; rep(j, n / g + 1) { if (r * i + g * j > n) continue; rep(k, n / b + 1) { if (r * i + g * j + b * k > n) break; if (r * i + g * j + b * k == n) cnt++; } } } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define ll long long #define P pair<ll, ll> #define all(v) (v).begin(), (v).end() const ll mod = 1e9 + 7; const ll INF = 1e18; const double pi = acos(-1); int main(void) { ll r, g, b, n, cnt = 0; cin >> r >> g >> b >> n; rep(i, n + 1) rep(j, n + 1) { ll x = r * i + g * j; if ((n - x) % b == 0 && x <= n) cnt++; } cout << cnt << endl; return 0; }
replace
15
28
15
19
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using namespace std; using P = pair<int, int>; typedef long long ll; int main() { int r, g, b, n; cin >> r >> g >> b >> n; long ans = 0; for (int i = 0; i <= n / r; i++) { for (int j = 0; j <= n / g; j++) { for (int k = 0; k <= n / b; k++) { if ((i * r) + (j * g) + (k * b) == n) ans++; } } } cout << ans << endl; return (0); }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using namespace std; using P = pair<int, int>; typedef long long ll; int main() { int r, g, b, n; cin >> r >> g >> b >> n; long ans = 0; for (int i = 0; i <= n / r; i++) { for (int j = 0; j <= n / g; j++) { if (n - ((i * r) + (j * g)) == 0) ans++; else if (n - ((i * r) + (j * g)) > 0) { if ((n - ((i * r) + (j * g))) % b == 0) ans++; } } } cout << ans << endl; return (0); }
replace
13
15
13
17
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ALL(A) A.begin(), A.end() const long long mod = 1000000007; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int sum = 0, ans = 0; for (int i = 0; i * r <= n; i++) { for (int j = 0; j * g + i * r <= n; j++) { for (int k = 0; k * b + i * r + j * g <= n; k++) { if (i * r + j * g + k * b == n) ans++; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ALL(A) A.begin(), A.end() const long long mod = 1000000007; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int sum = 0, ans = 0; for (int i = 0; i * r <= n; i++) { for (int j = 0; i * r + j * g <= n; j++) { if ((n - i * r - j * g) % b == 0) { ans++; } } } cout << ans << endl; return 0; }
replace
9
13
9
12
TLE