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 <algorithm> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; int INF = 1 << 29; int main() { ios::sync_with_stdio(false); 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 - R * i) / G; j++) { for (int k = 0; k <= (N - R * i - G * j) / B; k++) { if (R * i + G * j + B * k == N) ans++; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; int INF = 1 << 29; int main() { ios::sync_with_stdio(false); 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 - R * i) / G; j++) { if ((N - (R * i + G * j)) % B == 0) ans++; } } cout << ans << endl; return 0; }
replace
15
19
15
17
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; int max_r, max_g, max_b; max_r = N / R; max_g = N / G; max_b = N / B; for (int i = 0; i < max_r + 1; i++) { for (int j = 0; j < max_g + 1; j++) { for (int k = 0; k < max_b + 1; k++) { if (R * i + G * j + B * k == 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; int max_r, max_g, max_b; max_r = N / R; max_g = N / G; max_b = N / B; for (int i = 0; i < max_r + 1; i++) { for (int j = 0; j < max_g + 1; j++) { if ((N - (R * i + G * j)) % B == 0 and N - (R * i + G * j) >= 0) { count++; } } } cout << count << endl; }
replace
16
19
16
18
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 i = 0; i * r <= n; i++) { for (int j = 0; j * g + i * r <= n; j++) { for (int k = 0; k * b + j * g + i * r <= n; k++) { if (i * r + j * g + k * b == n) { cnt++; } } } } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b, n, cnt = 0; cin >> r >> g >> b >> n; for (int i = 0; i * r <= n; i++) { for (int j = 0; j * g + i * r <= n; j++) { if (i * r + j * g == n) { cnt++; } else if (i * r + j * g < n) { if ((n - (i * r + j * g)) % b == 0) { cnt++; } } } } cout << cnt; return 0; }
replace
10
12
10
14
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> #include <vector> // #include <string> #include <algorithm> #include <cmath> #include <iostream> #include <numeric> using namespace std; int main() { int r, g, b, n, ans = 0, tmp; cin >> r >> g >> b >> n; if (r < g) { tmp = r; r = g; g = tmp; } if (r < b) { tmp = r; r = b; b = tmp; } if (g < b) { tmp = g; g = b; b = tmp; } 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 (i * r + j * g + k * b == n) ans++; } } } cout << ans << endl; }
#include <iostream> #include <vector> // #include <string> #include <algorithm> #include <cmath> #include <iostream> #include <numeric> using namespace std; int main() { int r, g, b, n, ans = 0, tmp; cin >> r >> g >> b >> n; if (r < g) { tmp = r; r = g; g = tmp; } if (r < b) { tmp = r; r = b; b = tmp; } if (g < b) { tmp = g; g = b; b = tmp; } 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) ans++; } } cout << ans << endl; }
replace
33
37
33
35
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <unordered_map> #include <vector> using namespace std; #define intmax INT_MAX #define lmax LONG_MAX #define uintmax UINT_MAX #define ulmax ULONG_MAX #define llmax LLONG_MAX #define ll long long #define rep(i, a, N) for ((i) = (a); (i) < (N); (i)++) #define rrp(i, N, a) for ((i) = (N)-1; (i) >= (a); (i)--) #define llfor ll i, j, k #define sc(a) cin >> a #define pr(a) cout << a << endl #define pY puts("YES") #define pN puts("NO") #define py puts("Yes") #define pn puts("No") #define pnn printf("\n") #define sort(a) sort(a.begin(), a.end()) #define push(a, b) (a).push_back(b) #define llvec vector<vector<ll>> #define charvec vector<vector<char>> #define sizeoof(a, b) (a, vector<ll>(b)) #define llpvec vector<pair<ll, ll>> /*繰り上げ除算*/ ll cei(ll x, ll y) { ll ans = x / y; if (x % y != 0) ans++; return ans; } /*最大公約数*/ ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } /*最小公倍数*/ ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } /*n乗*/ ll llpow(ll x, ll n) { ll i, ans = 1; rep(i, 0, n) ans *= x; return ans; } /*階乗*/ ll fact(ll x) { ll i, ans = 1; rep(i, 0, x) ans *= (x - i); return ans; } /*nCr*/ ll ncr(ll n, ll r) { return fact(n) / fact(r) / fact(n - r); } /*nPr*/ ll npr(ll n, ll r) { return fact(n) / fact(n - r); } /*primejudge*/ bool prime(ll a) { if (a <= 1) return false; ll i; for (i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } llfor; /////////////////////////////////////////////////////////// int main() { ll r, g, b, n; sc(r); sc(g); sc(b); sc(n); ll k; ll ans = 0; ll a = cei(n, r), d = cei(n, g), c = cei(n, b); rep(i, 0, a + 1) { rep(j, 0, d + 1) { if (r * i + g * j > n) break; rep(k, 0, c + 1) { ll e = r * i + g * j + b * k; if (e == n) ans++; // cout<<i<<" "<<j<<" "<<k<<" "<<ans<<" "<<e<<endl; } } } pr(ans); return 0; }
#include <algorithm> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <unordered_map> #include <vector> using namespace std; #define intmax INT_MAX #define lmax LONG_MAX #define uintmax UINT_MAX #define ulmax ULONG_MAX #define llmax LLONG_MAX #define ll long long #define rep(i, a, N) for ((i) = (a); (i) < (N); (i)++) #define rrp(i, N, a) for ((i) = (N)-1; (i) >= (a); (i)--) #define llfor ll i, j, k #define sc(a) cin >> a #define pr(a) cout << a << endl #define pY puts("YES") #define pN puts("NO") #define py puts("Yes") #define pn puts("No") #define pnn printf("\n") #define sort(a) sort(a.begin(), a.end()) #define push(a, b) (a).push_back(b) #define llvec vector<vector<ll>> #define charvec vector<vector<char>> #define sizeoof(a, b) (a, vector<ll>(b)) #define llpvec vector<pair<ll, ll>> /*繰り上げ除算*/ ll cei(ll x, ll y) { ll ans = x / y; if (x % y != 0) ans++; return ans; } /*最大公約数*/ ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } /*最小公倍数*/ ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } /*n乗*/ ll llpow(ll x, ll n) { ll i, ans = 1; rep(i, 0, n) ans *= x; return ans; } /*階乗*/ ll fact(ll x) { ll i, ans = 1; rep(i, 0, x) ans *= (x - i); return ans; } /*nCr*/ ll ncr(ll n, ll r) { return fact(n) / fact(r) / fact(n - r); } /*nPr*/ ll npr(ll n, ll r) { return fact(n) / fact(n - r); } /*primejudge*/ bool prime(ll a) { if (a <= 1) return false; ll i; for (i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } llfor; /////////////////////////////////////////////////////////// int main() { ll r, g, b, n; sc(r); sc(g); sc(b); sc(n); ll k; ll ans = 0; ll a = cei(n, r), d = cei(n, g), c = cei(n, b); rep(i, 0, a + 1) { rep(j, 0, d + 1) { if (r * i + g * j > n) break; if ((n - r * i - g * j) % b == 0) ans++; } } pr(ans); return 0; }
replace
82
88
82
84
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; } int main() { ll R, G, B, N, ans = 0; cin >> R >> G >> B >> N; for (int i = 0; i <= N; i++) { for (int j = 0; j <= N - i * R; j++) { for (int k = 0; k <= N - i * R - j * G; k++) { if (k * B + i * R + j * G == N) { ans++; } } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; } int main() { ll R, G, B, N, ans = 0; cin >> R >> G >> B >> N; for (int i = 0; i <= N; i++) { for (int j = 0; j <= N - i * R; j++) { if ((N - (i * R + j * G)) / B >= 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> #include <iostream> using namespace std; #define REP(i, n) FOR(i, 0, n) #define FOR(i, a, b) for (int i = (a), i##Len_ = (b); i < i##Len_; i++) int main() { vector<int> X(4); vector<int> Y(4); REP(i, 4) { cin >> X[i]; } int a, b, res, cnt; REP(i, 4) { Y[i] = X[3] / X[i]; } vector<int> tes(3000 * 3000); for (int j = 0; j <= Y[0]; j++) { if (X[3] < X[0] * j) break; for (int k = 0; k <= Y[1]; k++) { if (X[3] < X[0] * j + X[1] * k) break; tes[cnt] = X[0] * j + X[1] * k; cnt++; } } for (int m = 0; m < cnt; m++) { b = X[3] - tes[m]; for (int l = 0; l <= Y[2]; l++) { if (b < X[2] * l) break; if (b == X[2] * l) { res++; break; } } } cout << res << endl; }
#include <bits/stdc++.h> #include <iostream> using namespace std; #define REP(i, n) FOR(i, 0, n) #define FOR(i, a, b) for (int i = (a), i##Len_ = (b); i < i##Len_; i++) int main() { vector<int> X(4); vector<int> Y(4); REP(i, 4) { cin >> X[i]; } int a, b, res, cnt; REP(i, 4) { Y[i] = X[3] / X[i]; } vector<int> tes(3000 * 3000); for (int j = 0; j <= Y[0]; j++) { if (X[3] < X[0] * j) break; for (int k = 0; k <= Y[1]; k++) { if (X[3] < X[0] * j + X[1] * k) break; tes[cnt] = X[0] * j + X[1] * k; cnt++; } } for (int m = 0; m < cnt; m++) { b = X[3] - tes[m]; // ここはあまりを求めるだけよい if (b % X[2] == 0) res++; } cout << res << endl; }
replace
32
40
32
35
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; constexpr int MAX_N = 3000; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; for (auto r = 0u; r <= MAX_N / R; ++r) { for (auto g = 0u; g <= (MAX_N - R * r) / G; ++g) { for (auto b = 0u; b <= (MAX_N - R * r - G * g) / B; ++b) { if (R * r + G * g + B * b == N) { ++count; } } } } cout << count; }
#include <iostream> using namespace std; constexpr int MAX_N = 3000; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; for (auto r = 0u; r <= MAX_N / R; ++r) { auto rc = R * r; for (auto g = 0u; g <= (MAX_N - rc) / G; ++g) { auto rest = N - rc - G * g; if (rest / B <= MAX_N && rest % B == 0) { ++count; } } } cout << count; }
replace
11
16
11
16
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; signed main() { long long 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; }
#include <bits/stdc++.h> using namespace std; signed main() { long long 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 - G * j >= 0 && (N - R * i - G * j) % B == 0) { count++; } } } cout << count << endl; }
replace
10
14
10
12
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <queue> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 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++) { int count = r * R + g * G + b * B; if (count == N) { ans += 1; } } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #include <queue> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; r <= (N / R); r++) { for (int g = 0; g <= ((N - r * R) / G); g++) { int count = r * R + g * G; if ((N - count) % B != 0) { continue; } int b = (N - count) / B; if (b >= 0) { ans += 1; } } } cout << ans << endl; return 0; }
replace
13
18
13
20
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()) #define VRSORT(v) sort(v.rbegin(), v.rend()) // vectorの降順ソート #define ll long long #define pb(a) push_back(a) #define INF 1000000000 #define MOD 1000000007 using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; typedef vector<unsigned int> vec; typedef vector<vec> mat; // typedef tuple<ll, ll, ll> T; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int dy[] = {0, 0, 1, -1, 0}; int dx[] = {1, -1, 0, 0, 0}; int main() { cin.tie(0); ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; ll ans = 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) ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()) #define VRSORT(v) sort(v.rbegin(), v.rend()) // vectorの降順ソート #define ll long long #define pb(a) push_back(a) #define INF 1000000000 #define MOD 1000000007 using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; typedef vector<unsigned int> vec; typedef vector<vec> mat; // typedef tuple<ll, ll, ll> T; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int dy[] = {0, 0, 1, -1, 0}; int dx[] = {1, -1, 0, 0, 0}; int main() { cin.tie(0); ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; ll ans = 0; for (int r = 0; r <= N; r++) { for (int g = 0; g <= N; g++) { int Bb = N - R * r - G * g; if (Bb >= 0 && Bb % B == 0) { // cout<<r<<":"<<g<<":"<<B*b<<endl; ans++; } } } cout << ans << endl; }
replace
43
48
43
49
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <stack> #include <string.h> #include <string> #include <vector> #define Z class #define ln cout << '\n' #define ll long long #define rep(i, n) for (int i = 0; i < (n); ++i) // ASCII a=97, A=65 // int H[N]; rep(i,N) scanf("%d", &H[i]); // int max_x = *std::max_element(x.begin(), x.end()); // int min_y = *std::min_element(y.begin(), y.end()); // sort(vec.begin(), vec.end()); std::greater<>() // reverse(vec.begin(), vec.end()); // scanf("%s",s); // printf("%d\n",end-start+1); // ceil (a + (b - 1)) / b using namespace std; 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; } template <Z A> void pr(A a) { cout << a; ln; } template <Z A, Z B> void pr(A a, B b) { cout << a << ' '; pr(b); } template <Z A, Z B, Z C> void pr(A a, B b, C c) { cout << a << ' '; pr(b, c); } template <Z A, Z B, Z C, Z D> void pr(A a, B b, C c, D d) { cout << a << ' '; pr(b, c, d); } template <Z A> void PR(A a, ll n) { rep(i, n) { if (i) cout << ' '; cout << a[i]; } ln; } int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } const long long INF = 1LL << 60; int main() { int A, B, C, D; cin >> A >> B >> C >> D; int res = 0; for (int i = 0; i <= D; i += A) { for (int j = 0; j <= D; j += B) { for (int k = 0; k <= D; k += C) { if (i + j + k == D) res++; } } } pr(res); }
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <stack> #include <string.h> #include <string> #include <vector> #define Z class #define ln cout << '\n' #define ll long long #define rep(i, n) for (int i = 0; i < (n); ++i) // ASCII a=97, A=65 // int H[N]; rep(i,N) scanf("%d", &H[i]); // int max_x = *std::max_element(x.begin(), x.end()); // int min_y = *std::min_element(y.begin(), y.end()); // sort(vec.begin(), vec.end()); std::greater<>() // reverse(vec.begin(), vec.end()); // scanf("%s",s); // printf("%d\n",end-start+1); // ceil (a + (b - 1)) / b using namespace std; 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; } template <Z A> void pr(A a) { cout << a; ln; } template <Z A, Z B> void pr(A a, B b) { cout << a << ' '; pr(b); } template <Z A, Z B, Z C> void pr(A a, B b, C c) { cout << a << ' '; pr(b, c); } template <Z A, Z B, Z C, Z D> void pr(A a, B b, C c, D d) { cout << a << ' '; pr(b, c, d); } template <Z A> void PR(A a, ll n) { rep(i, n) { if (i) cout << ' '; cout << a[i]; } ln; } int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } const long long INF = 1LL << 60; int main() { int A, B, C, D; cin >> A >> B >> C >> D; int res = 0; for (int i = 0; i <= D; i += A) { for (int j = 0; j <= D; j += B) { if (D - i - j >= 0 && (D - i - j) % C == 0) res++; } } pr(res); }
replace
74
78
74
76
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; ll ans = 0; int r_max = (N + R - 1) / R; int g_max = (N + G - 1) / G; int b_max = (N + B - 1) / B; rep(i, r_max + 1) rep(j, g_max + 1) rep(k, b_max + 1) { 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 < (n); i++) using ll = long long; using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; ll ans = 0; int r_max = (N + R - 1) / R; int g_max = (N + G - 1) / G; rep(i, r_max + 1) rep(j, g_max + 1) { int k = (N - i * R - j * G) / B; if (k < 0) break; if (i * R + j * G + k * B == N) ans++; } cout << ans << endl; return 0; }
replace
11
13
11
15
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> #include <iostream> #include <string.h> using namespace std; int main(void) { int R, G, B, N, answer = 0, num1, num2; cin >> R >> G >> B >> N; for (int i = 0; i <= N / R; i++) { num1 = N - R * i; for (int j = 0; j <= num1 / G; j++) { num2 = num1 - G * j; for (int k = 0; k <= num2 / B; k++) { if (R * i + G * j + B * k == N) { answer++; } } } } cout << answer << endl; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #include <string.h> using namespace std; int main(void) { int R, G, B, N, answer = 0, num1, num2; cin >> R >> G >> B >> N; for (int i = 0; i <= N / R; i++) { num1 = N - R * i; for (int j = 0; j <= num1 / G; j++) { num2 = num1 - G * j; if (num2 % B == 0) { answer++; } } } cout << answer << endl; return 0; }
replace
13
17
13
15
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define REP(i, a, b) for (int i = (int)(a); (i) < (int)(b); i++) typedef unsigned long long ull; typedef long long ll; const int INF = 1001001001; const ll MOD = 1e9 + 7; using namespace std; using P = pair<int, int>; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll c, ll d) { return c / gcd(c, d) * d; } int main() { ll r, g, b, n; cin >> r >> g >> b >> n; ll sum = 0; ll count = 0; rep(i, n / r + 1) { rep(j, n / g + 1) { rep(k, n / b + 1) { if (i + j > n) continue; sum = r * i + g * j + b * k; if (sum == n) count++; // cout << sum << " " << count << endl; // cout << i << " " << j << " " << n-i-j << " " << endl; } } } cout << count << endl; return 0; }
#include <bits/stdc++.h> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define REP(i, a, b) for (int i = (int)(a); (i) < (int)(b); i++) typedef unsigned long long ull; typedef long long ll; const int INF = 1001001001; const ll MOD = 1e9 + 7; using namespace std; using P = pair<int, int>; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll c, ll d) { return c / gcd(c, d) * d; } int main() { ll r, g, b, n; cin >> r >> g >> b >> n; ll sum = 0; ll count = 0; rep(i, 3001) { rep(j, 3001) { ll rem = r * i + g * j; if (n >= rem && (n - rem) % b == 0) count++; // cout << i << " " << j << " " << n-i-j << " " << endl; } } cout << count << endl; return 0; }
replace
23
34
23
29
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 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; }
#include <bits/stdc++.h> using namespace std; int main() { int 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++) { if ((N - R * r - G * g) % B == 0) ans++; } cout << ans << endl; }
replace
10
15
10
14
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; typedef long double ld; const ll INF = 1e+14; typedef pair<int, int> P; #define stop \ char nyaa; \ cin >> nyaa; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define per1(i, n) for (int i = n; i >= 1; i--) #define Rep1(i, sta, n) for (int i = sta; i <= n; i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second int main() { ios::sync_with_stdio(false); cin.tie(0); int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; rep(i, N / R + 1) { rep(j, (N - i * R) / G + 1) { rep(k, (N - i * R - j * G) / B + 1) { if (N - i * R - j * G - k * B == 0) { ans++; } } } } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; typedef long double ld; const ll INF = 1e+14; typedef pair<int, int> P; #define stop \ char nyaa; \ cin >> nyaa; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define per1(i, n) for (int i = n; i >= 1; i--) #define Rep1(i, sta, n) for (int i = sta; i <= n; i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second int main() { ios::sync_with_stdio(false); cin.tie(0); int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; rep(i, N / R + 1) { rep(j, (N - i * R) / G + 1) { int k; if ((N - i * R - j * G) % B == 0) { k = (N - i * R - j * G) / B; ans++; } } } cout << ans << endl; return 0; }
replace
50
54
50
54
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int cnt = 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 (N == R * r + G * g + B * b) cnt++; } } } cout << cnt << endl; return 0; }
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int cnt = 0; for (int r = 0; R * r <= N; r++) { for (int g = 0; G * g <= N; g++) { if (N < R * r + G * g) continue; if ((N - R * r - G * g) % B == 0) cnt++; } } cout << cnt << endl; return 0; }
replace
10
14
10
14
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int k = 0; for (int x = 0; x < N + 1; x++) { if (R * x > N) break; for (int y = 0; y < N + 1; y++) { if (R * x + G * y > N) break; for (int z = 0; z < N + 1; z++) { if (R * x + G * y + B * z > N) break; if (R * x + G * y + B * z == N) { k++; } } } } cout << k; cin >> k; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int k = 0; for (int x = 0; x < N + 1; x++) { if (R * x > N) break; for (int y = 0; y < N + 1; y++) { if (R * x + G * y > N) break; if ((N - R * x - G * y) % B == 0) { int z = (N - R * x - G * y) / B; if (R * x + G * y + B * z == N) { k++; } } } } cout << k; cin >> k; }
replace
17
20
17
19
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i) #define REV(i, a, b) for (int i = (a); i >= (b); --i) #define CLR(a, b) memset((a), (b), sizeof(a)) #define DUMP(x) cout << #x << " = " << (x) << endl; #define INF 1001001001001001001ll #define fcout cout << fixed << setprecision(10) using namespace std; template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; } template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } typedef pair<int, int> P; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int R, G, B, N; cin >> R >> G >> B >> N; int res = 0; for (int r = 0; r * R <= N; r++) { for (int b = 0; r * R + b * B <= N; b++) { for (int g = 0; r * R + b * B + g * G <= N; g++) { if (r * R + b * B + g * G == N) { res++; } } } } cout << res << endl; return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i) #define REV(i, a, b) for (int i = (a); i >= (b); --i) #define CLR(a, b) memset((a), (b), sizeof(a)) #define DUMP(x) cout << #x << " = " << (x) << endl; #define INF 1001001001001001001ll #define fcout cout << fixed << setprecision(10) using namespace std; template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; } template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } typedef pair<int, int> P; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int R, G, B, N; cin >> R >> G >> B >> N; int res = 0; for (int r = 0; r * R <= N; r++) { for (int b = 0; r * R + b * B <= N; b++) { int n = r * R + b * B; if ((N - n) % G == 0) { res++; } } } cout << res << endl; return 0; }
replace
70
74
70
73
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 r = 0; r * R <= N; r++) { for (int g = 0; g * G <= N - (r * R); g++) { for (int b = 0; b * B <= N - (r * R) - (g * G); b++) { if (r * R + g * G + b * B == N) res++; } } } cout << res << endl; }
#include <iostream> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int res = 0; for (int r = 0; r * R <= N; r++) { for (int g = 0; g * G <= N - (r * R); g++) { if ((N - (r * R + g * G)) % B == 0) res++; } } cout << res << endl; }
replace
9
13
9
12
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; const double EPS = 1e-9; const int INF = 1e9; const int MOD = 1e9 + 7; const ll LINF = 1e18; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef map<int, int> mi; typedef set<int> si; #define VV(T) vector<vector<T>> #define dump(x) cout << #x << " = " << (x) << endl #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl #define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl #define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl #define rep(i, n) REP(i, 0, n) // 0, 1, ..., n-1 #define REP(i, x, n) for (int i = x; i < n; i++) // x, x + 1, ..., n-1 #define FOREACH(x, a) for (auto &(x) : (a)) #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define pb push_back #define pu push #define mp make_pair #define fi first #define sc second #define COUT(x) cout << (x) << endl #define VECCIN(x) \ for (auto &youso_ : (x)) \ cin >> youso_ #define VECCOUT(x) \ for (auto &youso_ : (x)) \ cout << youso_ << " "; \ cout << 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; } int main() { cin.tie(0); ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; rep(r, N + 1) { rep(g, N + 1) { rep(b, N + 1) { if (r * R + g * G + b * B == N) { ans++; } if (r * R + g * G + b * B > N) break; } } } COUT(ans); }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const double EPS = 1e-9; const int INF = 1e9; const int MOD = 1e9 + 7; const ll LINF = 1e18; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef map<int, int> mi; typedef set<int> si; #define VV(T) vector<vector<T>> #define dump(x) cout << #x << " = " << (x) << endl #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl #define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl #define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl #define rep(i, n) REP(i, 0, n) // 0, 1, ..., n-1 #define REP(i, x, n) for (int i = x; i < n; i++) // x, x + 1, ..., n-1 #define FOREACH(x, a) for (auto &(x) : (a)) #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define pb push_back #define pu push #define mp make_pair #define fi first #define sc second #define COUT(x) cout << (x) << endl #define VECCIN(x) \ for (auto &youso_ : (x)) \ cin >> youso_ #define VECCOUT(x) \ for (auto &youso_ : (x)) \ cout << youso_ << " "; \ cout << 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; } int main() { cin.tie(0); ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; rep(r, N + 1) { rep(g, N + 1) { int b = (N - (R * r + G * g)) / B; if (N - (R * r + G * g + b * B) == 0 && b >= 0) { ans++; } } } COUT(ans); }
replace
66
72
66
69
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 answer = 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) answer++; } } } cout << answer; return 0; }
#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 <= (N / R); i++) { for (int j = 0; j <= (N - R * i) / G; j++) { if ((N - R * i - G * j) % B == 0) answer++; } } cout << answer; return 0; }
replace
8
12
8
10
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 r = R; int g = G; int b = B; int count = 0; for (int i = 0; i <= N; i += r) { for (int x = 0; x + i <= N; x += g) { for (int y = 0; y + x + i <= N; y += b) { if (y + x + i == N) { count += 1; } } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int r = R; int g = G; int b = B; int count = 0; if (R == G == B) { if (N % G == 0) { int xxx = N / R; int yyy = xxx + 2; int yyyy = xxx + 1; int yyyyy = yyy * yyyy; count = yyyyy / 2; } else { count = 0; } } else { for (int i = 0; i <= N; i += r) { for (int x = 0; x + i <= N; x += g) { for (int y = 0; y + x + i <= N; y += b) { if (y + x + i == N) { count += 1; } } } } } cout << count << endl; }
replace
10
15
10
27
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int a, b, c, ans, n, k, r, g; int main() { cin >> r >> g >> b >> n; for (int i = 0; i < (n / r) + 1; i++) { for (int u = 0; u < (n / g) + 1; u++) { for (int o = 0; o < (n / b) + 1; o++) { if ((i * r) + (u * g) + (o * b) == n) ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int a, b, c, ans, n, k, r, g; int main() { cin >> r >> g >> b >> n; for (int i = 0; i < n + 1; i += r) { if (i > n) break; for (int u = 0; u < n + 1; u += g) { if (u > n) break; int ll = n - i - u; if (ll < b && ll != 0) continue; if (ll == 0) { ans++; continue; } if (ll % b == 0 && ll / b != 0) { // cout<<i<<" "<<u<<" "<<ll/b<<endl; ans++; } } } cout << ans << endl; }
replace
7
12
7
23
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 repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++) #define rrep(i, n, m) for (int i = n; i >= m; i--) #define ALL(a) (a).begin(), (a).end() #define p(a, b) printf(a, b); #define c(s) cout << (s) << endl; #define yes cout << "Yes" << endl; #define no cout << "No" << endl; #define YES cout << "YES" << endl; #define NO cout << "NO" << endl; #define cyn(c) cout << (c ? "Yes" : "No") << endl; #define cYN(c) cout << (c ? "YES" : "NO") << endl; #define pyn(c) printf("%s\n", c ? "Yes" : "No"); #define pYN(c) printf("%s\n", c ? "YES" : "NO"); #define INF 1e18 typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> P; template <class T> bool contain(const std::string &s, const T &v) { return s.find(v) != std::string::npos; } ULL mod = 1e9 + 7; unsigned long long gcd(unsigned long long a, unsigned long long b) { while (1) { if (a < b) swap(a, b); if (!b) break; a %= b; } return a; } int main() { int R, G, B, N, ans = 0; cin >> R >> G >> B >> N; 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) { ans++; } } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++) #define rrep(i, n, m) for (int i = n; i >= m; i--) #define ALL(a) (a).begin(), (a).end() #define p(a, b) printf(a, b); #define c(s) cout << (s) << endl; #define yes cout << "Yes" << endl; #define no cout << "No" << endl; #define YES cout << "YES" << endl; #define NO cout << "NO" << endl; #define cyn(c) cout << (c ? "Yes" : "No") << endl; #define cYN(c) cout << (c ? "YES" : "NO") << endl; #define pyn(c) printf("%s\n", c ? "Yes" : "No"); #define pYN(c) printf("%s\n", c ? "YES" : "NO"); #define INF 1e18 typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> P; template <class T> bool contain(const std::string &s, const T &v) { return s.find(v) != std::string::npos; } ULL mod = 1e9 + 7; unsigned long long gcd(unsigned long long a, unsigned long long b) { while (1) { if (a < b) swap(a, b); if (!b) break; a %= b; } return a; } int main() { int R, G, B, N, 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 - (r * R + g * G)) >= 0 && ((N - (r * R + g * G)) <= N) && ((N - (r * R + g * G)) % B == 0)) { // cout << "r: " << r << " g: " << g << " b: " << (N - (r * R + g * G)) // / B << endl; ans++; } } } cout << ans << endl; }
replace
41
45
41
46
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) constexpr int INF = numeric_limits<int>::max() / 2; constexpr long long INFL = numeric_limits<long long>::max() / 2; constexpr int MOD = 1000000007; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int R, B, G, N; cin >> R >> B >> G >> N; int r = N / R; int b = N / B; int g = N / G; int ans = 0; rep(i, r + 1) { rep(j, b + 1) { rep(k, g + 1) { if (N == i * R + j * B + k * G) ans++; if (N < i * R + j * B + k * G) break; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) constexpr int INF = numeric_limits<int>::max() / 2; constexpr long long INFL = numeric_limits<long long>::max() / 2; constexpr int MOD = 1000000007; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int R, B, G, N; cin >> R >> B >> G >> N; int r = N / R; int b = N / B; int g = N / G; int ans = 0; rep(i, r + 1) { rep(j, (N - R * i) / B + 1) { if ((N - i * R - j * B) % G == 0) ans++; } } cout << ans << endl; }
replace
18
25
18
21
TLE
p03048
C++
Runtime Error
#include <cstdio> #include <iostream> using namespace std; int a, b, c, n, ans; int main() { freopen("input.txt", "r", stdin); int i, j, t; cin >> a >> b >> c >> n; for (i = 0; i <= 3000; i++) for (j = 0; j <= 3000; j++) { t = n - a * i - b * j; if (t < 0) break; if (t % c == 0) ans++; } cout << ans; return 0; }
#include <cstdio> #include <iostream> using namespace std; int a, b, c, n, ans; int main() { int i, j, t; cin >> a >> b >> c >> n; for (i = 0; i <= 3000; i++) for (j = 0; j <= 3000; j++) { t = n - a * i - b * j; if (t < 0) break; if (t % c == 0) ans++; } cout << ans; return 0; }
delete
7
8
7
7
-8
p03048
C++
Time Limit Exceeded
#include <iostream> #include <stdio.h> using namespace std; int R, G, B, N; int main() { cin >> R >> G >> B >> N; int ans = 0; 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) { // int b = N - (r + g); if ((r + g + b) == N) ans++; } } } cout << ans << endl; return 0; }
#include <iostream> #include <stdio.h> using namespace std; int R, G, B, N; int main() { cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; r <= N; r += R) { for (int g = 0; g <= N - r; g += G) { if ((N - (r + g)) % B == 0) ans++; } } cout << ans << endl; return 0; }
replace
10
15
10
12
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using ll = long long; using itn = int; using namespace std; int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int main() { int r, g, b, n; cin >> r >> g >> b >> n; ll cnt = 0; int rm = n / r, gm = n / g, bm = n / b; for (int i = 0; i <= rm; i++) { for (int j = 0; j <= gm; j++) { for (int k = 0; k <= bm; k++) { if ((i * r + j * g + k * b) == n) { cnt++; } } } } cout << cnt << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using ll = long long; using itn = int; using namespace std; int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int main() { int r, g, b, n; cin >> r >> g >> b >> n; ll cnt = 0; int rm = n / r, gm = n / g; for (int i = 0; i <= rm; ++i) { // G,Bが0個 if ((i * r) == n) { cnt++; continue; } for (int j = 0; j <= gm; ++j) { // Bが0個 if ((i * r + j * g) == n) { cnt++; continue; } // Bを取る場合 else if (((n - (i * r + j * g)) % b) == 0 && (n - (i * r + j * g) > 0)) { cnt++; continue; } } } cout << cnt << endl; return 0; }
replace
22
29
22
39
TLE
p03048
C++
Runtime Error
/* author: Apoorv Singh */ #include <bits/stdc++.h> using namespace std; typedef vector<long long> vi; typedef pair<long long, long long> pii; #define pb push_back #define all(c) c.begin(), c.end() #define watch(x) cout << (#x) << " " << (x) << endl; #define FOR(i, a, b) for (long long i = a; i < b; ++i) #define FORR(i, a, b) for (long long i = a; i > b; --i) #define um unordered_map #define F first #define S second #define int long long #define inf LLONG_MAX #define endl "\n" int modulo = 1e9 + 7; template <class X> void printarr(X arr[], int n) { for (int i = 0; i < n; ++i) cout << arr[i] << " "; cout << endl; } int fpow(int a, int n) { int ans = 1; while (n) { if (n & 1) ans = (ans * a) % modulo; a = (a * a) % modulo; n = n >> 1; } return ans; } /* const int M = 1e6 + 10; int composite[M] = {0}; void sieve() { FOR(i,2,M) { if (!composite[i]) { for (int j = 2*i; j < M; j += i) composite[j] = max(composite[j], i); } } } */ signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; FOR(i, 0, n + 1) { FOR(j, 0, n + 1) { if (r * i + g * j > n) continue; int x = r * i + g * j; if ((n - x) % b) continue; ++ans; } } cout << ans << endl; return 0; }
/* author: Apoorv Singh */ #include <bits/stdc++.h> using namespace std; typedef vector<long long> vi; typedef pair<long long, long long> pii; #define pb push_back #define all(c) c.begin(), c.end() #define watch(x) cout << (#x) << " " << (x) << endl; #define FOR(i, a, b) for (long long i = a; i < b; ++i) #define FORR(i, a, b) for (long long i = a; i > b; --i) #define um unordered_map #define F first #define S second #define int long long #define inf LLONG_MAX #define endl "\n" int modulo = 1e9 + 7; template <class X> void printarr(X arr[], int n) { for (int i = 0; i < n; ++i) cout << arr[i] << " "; cout << endl; } int fpow(int a, int n) { int ans = 1; while (n) { if (n & 1) ans = (ans * a) % modulo; a = (a * a) % modulo; n = n >> 1; } return ans; } /* const int M = 1e6 + 10; int composite[M] = {0}; void sieve() { FOR(i,2,M) { if (!composite[i]) { for (int j = 2*i; j < M; j += i) composite[j] = max(composite[j], i); } } } */ signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; FOR(i, 0, n + 1) { FOR(j, 0, n + 1) { if (r * i + g * j > n) continue; int x = r * i + g * j; if ((n - x) % b) continue; ++ans; } } cout << ans << endl; return 0; }
delete
63
67
63
63
TLE
p03048
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); typedef long long int ll; ll mod = 1e9 + 7; ll power(ll a, ll b) { if (b == 0) return 1; else if (b % 2 == 0) { return power(a * a, b / 2); } else return (a * power(a * a, b / 2)); } int main() { IOS #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("input.txt", "r", stdin); // for writing output to output.txt freopen("output.txt", "w", stdout); #endif int r, g, b, n; cin >> r >> g >> b >> n; int count = 0; for (int i = 0; i <= 3000; ++i) { for (int j = 0; j <= 3000; ++j) { int temp = n - i * r - j * g; if (temp < 0) continue; if (temp % b == 0) count++; } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); typedef long long int ll; ll mod = 1e9 + 7; ll power(ll a, ll b) { if (b == 0) return 1; else if (b % 2 == 0) { return power(a * a, b / 2); } else return (a * power(a * a, b / 2)); } int main() { IOS int r, g, b, n; cin >> r >> g >> b >> n; int count = 0; for (int i = 0; i <= 3000; ++i) { for (int j = 0; j <= 3000; ++j) { int temp = n - i * r - j * g; if (temp < 0) continue; if (temp % b == 0) count++; } } cout << count << endl; }
replace
21
28
21
24
0
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; signed main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 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++) { if (R * r + G * g + B * b == N) ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; signed main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; R * r <= N; r++) { for (int g = 0; R * r + G * g <= N; g++) { if (N > R * r + G * g && (N - R * r - G * g) % B == 0) { ans++; } else if (N == R * r + G * g) { ans++; } } } cout << ans << endl; }
replace
8
11
8
12
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define puts(i) cout << i << endl #define INF INT_MAX; #define INFL LLONG_MAX; typedef long long ll; using namespace std; int main() { int R, G, B, n; cin >> R >> G >> B >> n; int64_t ans = 0; for (int i = n / R; i >= 0; i--) { for (int j = (n - i) / G; j >= 0; j--) { for (int k = (n - i - j) / B; k >= 0; k--) { 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 < (int)(n); i++) #define all(v) v.begin(), v.end() #define puts(i) cout << i << endl #define INF INT_MAX; #define INFL LLONG_MAX; typedef long long ll; using namespace std; int main() { int R, G, B, n; cin >> R >> G >> B >> n; int64_t ans = 0; for (int i = n / R; i >= 0; i--) { for (int j = (n - i) / G; j >= 0; j--) { if ((n - R * i - G * j) >= 0 && (n - R * i - G * j) % B == 0) ans++; } } cout << ans << endl; }
replace
16
20
16
18
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <regex> #include <set> #include <string> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int r = 0, g = 0, b = 0, ans = 0; for (r = 0; r <= N; r++) { for (g = 0; g <= N; g++) { for (b = 0; b <= N; b++) { int tmp = (R * r) + (G * g) + (B * b); if (tmp == N) { ans++; } } } } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <regex> #include <set> #include <string> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int r = 0, g = 0, b = 0, ans = 0; for (r = 0; r <= N; r++) { for (g = 0; g <= N; g++) { int tmp = (R * r) + (G * g); if (tmp <= N && (N - tmp) % B == 0) { ans++; } } } cout << ans << endl; return 0; }
replace
15
20
15
18
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #pragma GCC target("avx2") #pragma GCC optimization("unroll-loops") #define rep(i, n) for (int i = 0; i < (int)(n); ++i) template <typename T> ll gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> ll lcm(T a, T b) { return a * b / gcd(a, b); }; template <typename T> inline void chmin(T &a, const T &b) { if (a > b) a = b; } template <typename T> inline void chmax(T &a, const T &b) { if (a < b) a = b; } int main() { ios::sync_with_stdio(false); cin.tie(0); int r, g, b, n; cin >> r >> g >> b >> n; ll ans = 0; for (int i = 0; r * i <= n; ++i) { for (int j = 0; r * i + g * j <= n; ++j) { for (int k = 0; r * i + g * j + b * k <= n; ++k) { if (r * i + g * j + b * k == n) { ++ans; } } } } cout << ans << '\n'; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #pragma GCC target("avx2") #pragma GCC optimization("unroll-loops") #define rep(i, n) for (int i = 0; i < (int)(n); ++i) template <typename T> ll gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> ll lcm(T a, T b) { return a * b / gcd(a, b); }; template <typename T> inline void chmin(T &a, const T &b) { if (a > b) a = b; } template <typename T> inline void chmax(T &a, const T &b) { if (a < b) a = b; } int main() { ios::sync_with_stdio(false); cin.tie(0); int r, g, b, n; cin >> r >> g >> b >> n; ll ans = 0; for (int i = 0; r * i <= n; ++i) { for (int j = 0; r * i + g * j <= n; ++j) { if (!((n - r * i - g * j) % b)) ++ans; } } cout << ans << '\n'; }
replace
26
31
26
28
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; vector<int> rgb(3, 0); rgb[0] = R; rgb[1] = G; rgb[2] = B; int rmax = N / R; int gmax = N / G; int bmax = N / B; int count = 0; for (int i = 0; i <= rmax; i++) { for (int j = 0; j <= gmax; j++) { for (int k = 0; k <= bmax; k++) { int sum = i * R + j * G + k * B; if (sum == N) { count += 1; } } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; vector<int> rgb(3, 0); rgb[0] = R; rgb[1] = G; rgb[2] = B; int rmax = N / R; int gmax = N / G; int bmax = N / B; int count = 0; for (int i = 0; i <= rmax; i++) { for (int j = 0; j <= gmax; j++) { int left = N - i * R - j * G; if (left >= 0 && left % B == 0) { count += 1; } } } cout << count << endl; }
replace
20
25
20
23
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 cnt = 0; for (int r = 0; r <= (3000 / R) + 1; r++) { for (int g = 0; g <= (3000 / G) + 1; g++) { if (r * R + g * G > N) break; for (int b = 0; b <= (3000 / B) + 1; b++) { if (r * R + g * G + b * B == N) { cnt++; } } } } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int cnt = 0; for (int r = 0; r <= (3000 / R) + 1; r++) { for (int g = 0; g <= (3000 / G) + 1; g++) { if ((N - r * R - g * G) % B == 0 && r * R + g * G <= N) cnt++; } } cout << cnt << endl; return 0; }
replace
9
16
9
11
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 sum = 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) { sum++; } } } } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int sum = 0; 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) { sum++; } } } cout << sum << endl; return 0; }
replace
9
13
9
11
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; using namespace std; const long long int INF = 1e18; const long long int mod = 1e9 + 7; typedef pair<ll, ll> pairs; typedef vector<pairs> p; ll gcd(ll A, ll B) { if (A % B == 0) return (B); else return (gcd(B, A % B)); } ll keta(ll N) { int tmp{}; while (N > 0) { tmp += (N % 10); N /= 10; } N = tmp; return N; } vector<vector<ll>> combination(ll n, ll r) { vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0)); for (ll i = 0; i < v.size(); ++i) { v[i][0] = 1; v[i][i] = 1; } for (ll i = 1; i < v.size(); ++i) { for (ll j = 0; j < i; ++j) { v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]); } } return v; } bool kai(string S) { bool flag = true; for (ll i = 0; i < S.size() / 2; ++i) { if (S[i] != S[S.size() - i - 1]) { flag = false; break; } } return flag; } // --------------------------------------------- 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 / g; ++j) { for (ll k = 0; k <= n / b; ++k) { ll flag = r * i + g * j + b * k; if (flag == n) { ans++; } } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; using namespace std; const long long int INF = 1e18; const long long int mod = 1e9 + 7; typedef pair<ll, ll> pairs; typedef vector<pairs> p; ll gcd(ll A, ll B) { if (A % B == 0) return (B); else return (gcd(B, A % B)); } ll keta(ll N) { int tmp{}; while (N > 0) { tmp += (N % 10); N /= 10; } N = tmp; return N; } vector<vector<ll>> combination(ll n, ll r) { vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0)); for (ll i = 0; i < v.size(); ++i) { v[i][0] = 1; v[i][i] = 1; } for (ll i = 1; i < v.size(); ++i) { for (ll j = 0; j < i; ++j) { v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]); } } return v; } bool kai(string S) { bool flag = true; for (ll i = 0; i < S.size() / 2; ++i) { if (S[i] != S[S.size() - i - 1]) { flag = false; break; } } return flag; } // --------------------------------------------- int main() { ll r, g, b, n; cin >> r >> g >> b >> n; ll ans = 0; for (ll i = 0; i <= n; ++i) { for (ll j = 0; j <= n; ++j) { ll flag = n - (r * i + g * j); if (flag % b == 0 and flag >= 0) { ans++; } } } cout << ans << endl; return 0; }
replace
56
63
56
61
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define froop1(a, n) for (int i = a; i < n; i++) #define froop2(a, n) for (int i = a; i > n; i--) int main() { int N, r, g, b, count; cin >> r >> g >> b >> N; froop1(0, N / r + 1) { for (int j = 0; j < (N - i * r) / g + 1; j++) { for (int k = 0; k < (N - i * r - j * g) / b + 1; k++) { if (r * i + g * j + b * k == N) { count++; } } } } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define froop1(a, n) for (int i = a; i < n; i++) #define froop2(a, n) for (int i = a; i > n; i--) int main() { int N, r, g, b, count; cin >> r >> g >> b >> N; froop1(0, N / r + 1) { for (int j = 0; j < (N - i * r) / g + 1; j++) { if ((N - r * i - g * j) % 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, a = 0; cin >> r >> g >> b >> n; for (int i = 0; i <= n / r; i++) { for (int j = 0; j <= (n - i * r) / g; j++) { int p = n - i * r - j * g; for (int k = 0; k <= p / b; k++) { if (n == i * r + j * g + k * b) 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 <= n / r; i++) { for (int j = 0; j <= (n - i * r) / g; j++) { if ((n - i * r - j * g) % b == 0) a++; } } cout << a << endl; }
replace
7
12
7
9
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 <= 3000; i++) { for (int j = 0; j <= 3000 - i; j++) { for (int k = 0; k <= 3000 - i - j; k++) { int A = R * i + G * j + B * k; if (A == N) ans++; } } } cout << ans << endl; }
#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; i++) { for (int j = 0; j <= N; j++) { int A = R * i + G * j; int n = N - A; // cout << n << endl; if (n >= 0 && n % B == 0) ans++; } } cout << ans << endl; }
replace
6
13
6
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 ans = 0; for (int r = 0; r < N / R + 1; r++) { int tmp = N - (R * r); if (tmp < 0) break; for (int g = 0; g < tmp / G + 1; g++) { int tmp = N - (R * r + G * g); if (tmp < 0) break; for (int b = 0; b < tmp / B + 1; b++) { if (R * r + G * g + B * b == N) { ans++; // cout << r << g << b << endl; } } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; r < N / R + 1; r++) { int tmp = N - (R * r); if (tmp < 0) break; for (int g = 0; g < tmp / G + 1; g++) { int tmp = N - (R * r + G * g); if (tmp < 0) break; if (tmp % B == 0) ans++; } } cout << ans << endl; return 0; }
replace
17
23
17
19
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> int main() { int R, G, B, N; std::cin >> R; std::cin >> G; std::cin >> B; std::cin >> N; int result = 0; for (int r = 0, r_limit = N / R; r <= r_limit; ++r) { int r_buy = r * R; for (int g = 0, g_limit = (N - r_buy) / G; g <= g_limit; ++g) { int g_buy = g * G; for (int b = 0, b_limit = (N - g_buy) / B; b <= b_limit; ++b) { int b_buy = b * B; if (r_buy + g_buy + b_buy == N) { ++result; } } } } std::cout << result; return 0; }
#include <iostream> int main() { int R, G, B, N; std::cin >> R; std::cin >> G; std::cin >> B; std::cin >> N; int result = 0; for (int r = 0, r_limit = N / R; r <= r_limit; ++r) { int r_buy = r * R; for (int g = 0, g_limit = (N - r_buy) / G; g <= g_limit; ++g) { int g_buy = g * G; if (((N - r_buy - g_buy) % B) == 0) { ++result; } } } std::cout << result; return 0; }
replace
15
20
15
17
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using ll = long long; using Pii = std::pair<int, int>; using Pll = std::pair<ll, ll>; const ll INF = (ll)1e11; using namespace std; int main() { ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; r <= N / R + 1; ++r) { for (int g = 0; g <= (N - r * R) / G + 1; ++g) { for (int b = 0; b <= (N - r * R - g * G) / B + 1; ++b) { if (r * R + g * G + b * B > N) break; if (r * R + g * G + b * B == N) ++ans; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using ll = long long; using Pii = std::pair<int, int>; using Pll = std::pair<ll, ll>; const ll INF = (ll)1e11; using namespace std; int main() { ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; r <= N / R + 1; ++r) { for (int g = 0; g <= (N - r * R) / G + 1; ++g) { if (r * R + g * G > N) break; if ((N - r * R - g * G) % B == 0) ++ans; } } cout << ans << endl; return 0; }
replace
19
25
19
23
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep0(i, n) for (long long i = 0; i < (long long)(n); i++) #define rep1(i, n) for (long long i = 1; i <= (long long)(n); i++) #define all(v) v.begin(), v.end() #define Sort(v) sort(all(v)) #define Reverse(v) reverse(all(v)) #define Rsort(v) sort(all(v), greater) #define pub(v) push_back(v) #define pob(v) pop_back(v) typedef long long ll; typedef vector<ll> vel; typedef vector<vector<ll>> vel2d; typedef string str; typedef pair<ll, ll> pal; int main() { ll R, G, B, N, cnt = 0; cin >> R >> G >> B >> N; for (ll r = 0; r * R <= N; r++) { for (ll g = 0; r * R + g * G <= N; g++) { for (ll b = 0; b * B + r * R + g * G <= N; b++) { if (b * B + r * R + g * G == N) { cnt++; } } } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; #define rep0(i, n) for (long long i = 0; i < (long long)(n); i++) #define rep1(i, n) for (long long i = 1; i <= (long long)(n); i++) #define all(v) v.begin(), v.end() #define Sort(v) sort(all(v)) #define Reverse(v) reverse(all(v)) #define Rsort(v) sort(all(v), greater) #define pub(v) push_back(v) #define pob(v) pop_back(v) typedef long long ll; typedef vector<ll> vel; typedef vector<vector<ll>> vel2d; typedef string str; typedef pair<ll, ll> pal; int main() { ll R, G, B, N, cnt = 0; cin >> R >> G >> B >> N; for (ll r = 0; r * R <= N; r++) { for (ll g = 0; g * G <= N; g++) { ll bB = N - (r * R + g * G); if (bB % B == 0 && bB >= 0) { cnt++; } } } cout << cnt << endl; }
replace
20
25
20
24
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> int main() { int R, G, B, N; std::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) { int n = R * i + G * j + B * k; if (n == N) ++ans; else if (n > N) break; } } } std::cout << ans << std::endl; return 0; }
#include <iostream> int main() { int R, G, B, N; std::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 k = N - R * i - G * j; if (k >= 0 && k % B == 0) ++ans; } } std::cout << ans << std::endl; return 0; }
replace
9
16
9
12
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; int main(void) { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; for (int r = 0; R * r <= N; r++) { for (int g = 0; G * g <= N - R * r; g++) { for (int b = 0; B * b <= N - R * r - G * g; b++) { if (r * R + g * G + b * B == N) { count++; } } } } cout << count << endl; }
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; int main(void) { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; for (int r = 0; R * r <= N; r++) { for (int g = 0; G * g <= N - R * r; g++) { if ((N - R * r - G * g) % B == 0) { // for (int b = 0; B * b <= N - R * r - G * g; b++) { // if (r * R + g * G + b * B == N) { count++; // } } } } cout << count << endl; }
replace
20
24
20
25
TLE
p03048
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define ld long double #define pr pair<ll, ll> #define loop(i, n) for (ll i = 0; i < n; ++i) #define rep(i, x, n) for (ll i = x; i <= n; ++i) #define iteloop(type, data, name, it) \ for (type<data>::iterator it = name.begin(); it != name.end(); ++it) using namespace std; const ll N = 2e2 + 5; int a, b, c, n; int main() { cin.sync_with_stdio(false), cin.tie(0), cout.tie(0); #ifndef ONLINE_JUDGE freopen("in.txt", "rt", stdin); // freopen("out.txt", "wt" , stdout); #endif // ONLINE_JUDGE cin >> a >> b >> c >> n; int ans = 0; loop(i, n + 1) { loop(j, n + 1) { int total = i * a + j * b; if (total > n) continue; if ((n - total) % c == 0) ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> #define ll long long #define ld long double #define pr pair<ll, ll> #define loop(i, n) for (ll i = 0; i < n; ++i) #define rep(i, x, n) for (ll i = x; i <= n; ++i) #define iteloop(type, data, name, it) \ for (type<data>::iterator it = name.begin(); it != name.end(); ++it) using namespace std; const ll N = 2e2 + 5; int a, b, c, n; int main() { cin.sync_with_stdio(false), cin.tie(0), cout.tie(0); #ifndef ONLINE_JUDGE // freopen("in.txt", "rt" , stdin); // freopen("out.txt", "wt" , stdout); #endif // ONLINE_JUDGE cin >> a >> b >> c >> n; int ans = 0; loop(i, n + 1) { loop(j, n + 1) { int total = i * a + j * b; if (total > n) continue; if ((n - total) % c == 0) ans++; } } cout << ans << endl; }
replace
15
16
15
16
-8
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define pb(x) push_back(x) #define mp(x, y) make_pair(x, y) #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define ll long long #define mod 1000000007 using namespace std; // ll cnt; int main() { IOS; int r, g, b, n; cin >> r >> g >> b >> n; int cnt = 0; for (int y = 0; y <= n / r; y++) { for (int x = 0; x <= n / g; x++) { for (int h = 0; h <= n / b; h++) { if (y * r + x * g + h * b == n) cnt++; } } } cout << cnt << "\n"; return 0; }
#include <bits/stdc++.h> #define pb(x) push_back(x) #define mp(x, y) make_pair(x, y) #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define ll long long #define mod 1000000007 using namespace std; // ll cnt; int main() { IOS; int r, g, b, n; cin >> r >> g >> b >> n; int cnt = 0; for (int y = 0; y <= n / r; y++) { for (int x = 0; x <= n / g; x++) { if (y * r + x * g == n) cnt++; else if ((n - y * r - x * g) % b == 0 && n - y * r - x * g > 0) cnt++; } } cout << cnt << "\n"; return 0; }
replace
21
25
21
25
TLE
p03048
C++
Runtime Error
#include <iostream> using namespace std; int main(void) { int R, G, B, N, tmp, count = 0; cin >> R >> G >> B >> N; for (int i = 0; R * i <= N; i++) { for (int j = 0; R * i + G * j <= N; j++) { tmp = N - (R * i + G * j); if (N % tmp == 0) count++; } } cout << count << "\n"; }
#include <iostream> using namespace std; int main(void) { int R, G, B, N, tmp, count = 0; cin >> R >> G >> B >> N; for (int i = 0; R * i <= N; i++) { for (int j = 0; R * i + G * j <= N; j++) { tmp = N - (R * i + G * j); if (tmp % B == 0) count++; } } cout << count << "\n"; }
replace
9
10
9
10
-8
p03048
C++
Runtime Error
#include <cstdio> #include <iostream> using namespace std; int x, n; int f[5000]; int main() { f[0] = 1; for (register int i = 1; i <= 3; i++) { scanf("%d", &x); for (register int j = 0; j <= 5000; j++) { if (f[j]) f[j + x] += f[j]; } } scanf("%d", &n); printf("%d\n", f[n]); return 0; }
#include <cstdio> #include <iostream> using namespace std; int x, n; int f[10000]; int main() { f[0] = 1; for (register int i = 1; i <= 3; i++) { scanf("%d", &x); for (register int j = 0; j <= 5000; j++) { if (f[j]) f[j + x] += f[j]; } } scanf("%d", &n); printf("%d\n", f[n]); return 0; }
replace
4
5
4
5
0
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; 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; 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> #define rep(i, a, n) for (int i = a; 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; i * r + j * g <= n; j++) { if ((n - i * r - j * g) % b == 0) ans++; } } cout << ans << endl; return 0; }
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 count = 0; int rmax = n / r; int gmax = n / g; int bmax = n / b; for (int i = 0; i <= rmax; i++) { for (int j = 0; j <= gmax; j++) { for (int k = 0; k <= bmax; k++) { if (n == r * i + g * j + b * k) count++; } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int count = 0; int rmax = n / r; int gmax = n / g; int bmax = n / b; for (int i = 0; i <= rmax; i++) { for (int j = 0; j <= (n - r * i) / g; j++) { if ((n - r * i - g * j) % b == 0) count++; } } cout << count << endl; }
replace
11
16
11
14
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define INF INT_MAX using namespace std; typedef long long ll; typedef pair<int, int> pii; int main(void) { 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 <= N; i += R) { for (int j = 0; j + i <= N; j += B) { for (int k = 0; k + j + i <= N; k += G) { if (i + j + k == N) { ans++; } } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define INF INT_MAX using namespace std; typedef long long ll; typedef pair<int, int> pii; int main(void) { 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 <= N; i += R) { for (int j = 0; j + i <= N; j += B) { if ((N - (i + j)) % G == 0) { ans++; } } } cout << ans << endl; return 0; }
replace
17
21
17
19
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; rep(i, (N - 1) / R + 2) { rep(j, (N - 1) / G + 2) { rep(k, (N - 1) / B + 2) { if (R * i + G * j + B * k == N) count++; } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; rep(i, 3001) { rep(j, 3001) { if ((N - R * i - G * j) % B == 0 && (N - R * i - G * j) / B >= 0) count++; } } cout << count << endl; }
replace
9
15
9
13
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define FOR(i, start, end) for (int i = start; i <= end; i++) const int INF = 1001001001; typedef long long ll; const ll MOD = 1000000007; using namespace std; 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; } template <class T> auto MAX(const T &a) { return *max_element(a.begin(), a.end()); } template <class T> auto MIN(const T &a) { return *min_element(a.begin(), a.end()); } template <class T, class U> U SUM(const T &a, const U &v) { return accumulate(a.begin(), a.end(), v); } template <class T, class U> U COUNT(const T &a, const U &v) { return count(a.begin(), a.end(), v); } template <class T, class U> int LOWER(const T &a, const U &v) { return lower_bound(a.begin(), a.end(), v) - a.begin(); } template <class T, class U> int UPPER(const T &a, const U &v) { return upper_bound(a.begin(), a.end(), v) - a.begin(); } int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; } //--------------------------------------------------------------------------------------------------- template <int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) {} ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; template <int MOD> ostream &operator<<(ostream &st, const ModInt<MOD> a) { st << a.get(); return st; }; template <int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) { ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; } template <typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac; Comb() { fac.resize(FAC_MAX, 1); ifac.resize(FAC_MAX, 1); FOR(i, 1, FAC_MAX - 1) fac[i] = fac[i - 1] * i; ifac[FAC_MAX - 1] = T(1) / fac[FAC_MAX - 1]; for (int i = FAC_MAX - 2; i >= 1; i--) ifac[i] = ifac[i + 1] * T(i + 1); } T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; } T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; } T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0; return aCb(n + k - 1, k); } // nHk = (n+k-1)Ck : n is separator T pairCombination(int n) { if (n % 2 == 1) return T(0); return fac[n] * ifac[n / 2] / (T(2) ^ (n / 2)); } // combination of paris for n }; typedef ModInt<1000000007> mint; bool isPrime(int x) { int i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0; return 1; } int main(void) { // Your code here! int R, G, B, N; cin >> R >> G >> B >> N; ll cnt = 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++) { if (r * R + g * G + b * B == N) cnt++; } } } cout << cnt << endl; } // 基本的にはlong long を使いましょう
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define FOR(i, start, end) for (int i = start; i <= end; i++) const int INF = 1001001001; typedef long long ll; const ll MOD = 1000000007; using namespace std; 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; } template <class T> auto MAX(const T &a) { return *max_element(a.begin(), a.end()); } template <class T> auto MIN(const T &a) { return *min_element(a.begin(), a.end()); } template <class T, class U> U SUM(const T &a, const U &v) { return accumulate(a.begin(), a.end(), v); } template <class T, class U> U COUNT(const T &a, const U &v) { return count(a.begin(), a.end(), v); } template <class T, class U> int LOWER(const T &a, const U &v) { return lower_bound(a.begin(), a.end(), v) - a.begin(); } template <class T, class U> int UPPER(const T &a, const U &v) { return upper_bound(a.begin(), a.end(), v) - a.begin(); } int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; } //--------------------------------------------------------------------------------------------------- template <int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) {} ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; template <int MOD> ostream &operator<<(ostream &st, const ModInt<MOD> a) { st << a.get(); return st; }; template <int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) { ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; } template <typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac; Comb() { fac.resize(FAC_MAX, 1); ifac.resize(FAC_MAX, 1); FOR(i, 1, FAC_MAX - 1) fac[i] = fac[i - 1] * i; ifac[FAC_MAX - 1] = T(1) / fac[FAC_MAX - 1]; for (int i = FAC_MAX - 2; i >= 1; i--) ifac[i] = ifac[i + 1] * T(i + 1); } T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; } T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; } T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0; return aCb(n + k - 1, k); } // nHk = (n+k-1)Ck : n is separator T pairCombination(int n) { if (n % 2 == 1) return T(0); return fac[n] * ifac[n / 2] / (T(2) ^ (n / 2)); } // combination of paris for n }; typedef ModInt<1000000007> mint; bool isPrime(int x) { int i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0; return 1; } int main(void) { // Your code here! int R, G, B, N; cin >> R >> G >> B >> N; ll cnt = 0; for (int r = 0; r * R <= N; r++) { for (int g = 0; r * R + g * G <= N; g++) { int amari = N - (r * R + g * G); if (amari % B == 0) cnt++; } } cout << cnt << endl; } // 基本的にはlong long を使いましょう
replace
160
164
160
163
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; const ll INF = LLONG_MAX; int main() { 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 + 1 - R; G += g) { for (int B = 0; B < n + 1 - R - G; B += b) { if (R + G + B == n) { ans++; } } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; const ll INF = LLONG_MAX; int main() { 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 + 1 - R; G += g) { if ((n - R - G) % b == 0) ans++; } } cout << ans << endl; }
replace
12
17
12
14
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> using namespace std; 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 - i * r) / g; ++j) { for (int k = 0; k <= (n - i * r - j * g) / b; ++k) { if (i * r + j * g + k * b == n) cnt++; } } } cout << cnt << endl; return 0; }
#include <iostream> using namespace std; 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 - i * r) / g; ++j) { if ((n - (i * r + j * g)) % b == 0) cnt++; } } cout << cnt << endl; return 0; }
replace
10
14
10
12
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main(int argc, char const *argv[]) { 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; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main(int argc, char const *argv[]) { 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) { int temp = n - r * i - g * j; // cout << temp << endl; if (temp % b == 0 && temp / b >= 0) cnt++; } } cout << cnt << endl; return 0; }
replace
12
16
12
16
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; int r = N / R + 1; int g = N / G + 1; int b = N / B + 1; for (int i = 0; i < r; i++) { int sum = i * R; for (int j = 0; j < g; j++) { int sum_sub = sum; sum_sub += j * G; for (int k = 0; k < b; k++) { int sum_sub_sub = sum_sub; sum_sub_sub += k * B; if (sum_sub_sub == N) { count += 1; } } } } cout << count << endl; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; int r = N / R + 1; int g = N / G + 1; int b = N / B + 1; for (int i = 0; i < r; i++) { int sum = i * R; for (int j = 0; j < g; j++) { int sum_sub = sum; sum_sub += j * G; if ((N - sum_sub) >= 0 && (N - sum_sub) % B == 0) { count += 1; } } } cout << count << endl; }
replace
19
25
19
21
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; int r = N / R; int g = N / G; int b = N / B; for (int i = 0; i <= r; i++) { for (int j = 0; j <= g; j++) { for (int m = 0; m <= b; m++) { if (N == R * i + G * j + B * m) { ans++; } } } } cout << ans; }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; int r = N / R; int g = N / G; int b = N / B; for (int i = 0; i <= r; i++) { for (int j = 0; j <= g; j++) { if ((N - (R * i + G * j)) % B == 0 && N - (R * i + G * j) >= 0) ans++; } } cout << ans; }
replace
15
20
15
17
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> 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 / g; j++) { for (int k = 0; k <= n / b; k++) { if (r * i + g * j + b * k == n) ans++; } } } cout << ans << endl; }
#include <bits/stdc++.h> 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 / g; j++) { if ((n - r * i - g * j) % b == 0 && (n - r * i - g * j) >= 0) ans++; } } cout << ans << endl; }
replace
8
12
8
10
TLE
p03048
C++
Time Limit Exceeded
// to format a document: ctrl + K -> ctrl + D #include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int i = 0; i <= N; i += R) { for (int j = 0; j <= N - i; j += G) { for (int k = 0; k <= N - i - j; k += B) { if (i + j + k == N) ans++; } } } cout << ans << endl; return 0; }
// to format a document: ctrl + K -> ctrl + D #include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; for (int i = 0; i <= N; i += R) { for (int j = 0; j <= N - i; j += G) { if ((N - i - j) % B == 0) ans++; } } cout << ans << endl; return 0; }
replace
17
21
17
19
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b, n; vector<int> input(3); cin >> input[0] >> input[1] >> input[2] >> n; sort(input.begin(), input.end()); r = input[2]; g = input[1]; b = input[0]; int ans = 0; int r_n = n / r; int g_n = n / g; int b_n = n / b; for (int i = 0; i <= r_n; i++) { for (int j = 0; j <= g_n; j++) { if (r * i + g * j > n) break; for (int k = 0; k <= b_n; k++) { if (r * i + g * j + b * k == n) { ans++; } } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int r, g, b, n; vector<int> input(3); cin >> input[0] >> input[1] >> input[2] >> n; sort(input.begin(), input.end()); r = input[2]; g = input[1]; b = input[0]; int ans = 0; int r_n = n / r; int g_n = n / g; int b_n = n / b; for (int i = 0; i <= r_n; i++) { for (int j = 0; j <= g_n; j++) { if ((n - r * i - g * j) % b == 0 && (n - r * i - g * j) / b >= 0) ans++; } } cout << ans << endl; return 0; }
replace
19
26
19
21
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main(void) { int R, G, B, N, a, ans = 0; cin >> R >> B >> G >> 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++) { a = R * i + B * k + G * j; if (N == a) { ans++; } } } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int R, G, B, N, a, ans = 0; cin >> R >> B >> G >> N; for (int i = 0; i * R <= N; i++) { for (int j = 0; i * R + j * G <= N; j++) { a = R * i + G * j; if ((N - a) % B == 0 && N >= a) { ans++; } } } cout << ans << "\n"; return 0; }
replace
9
14
9
12
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <math.h> #include <string.h> #include <vector> typedef long long ll; using namespace std; ll Mod = 1e9 + 7; 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 / G; j++) { for (int k = 0; k <= N / B; k++) { // cout << i << " " << j << " " << k << endl; if (i * R + j * G + k * B == N) ans++; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <string.h> #include <vector> typedef long long ll; using namespace std; ll Mod = 1e9 + 7; 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 / G; j++) { if (i * R + j * G > N) continue; if ((N - i * R - j * G) % B == 0) { ans++; // cout << i << " " << j << endl; } } } cout << ans << endl; return 0; }
replace
16
20
16
21
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <climits> #include <iostream> #include <set> #include <string> #include <vector> #define MAX 1000000007 using namespace std; #define ll long long #define dbg if (1) #define ISRANGE(val, lo, hi) ((lo <= val) && (val < hi)) int main() { ll ans, r, g, b, n; ans = 0; cin >> r >> g >> b >> n; for (int i = 0; i * r <= n; i++) { for (int j = 0; j * g + i * r <= n; j++) { for (int k = 0; k * b + j * g + i * r <= n; k++) { if (k * b + j * g + i * r == n) ans++; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <climits> #include <iostream> #include <set> #include <string> #include <vector> #define MAX 1000000007 using namespace std; #define ll long long #define dbg if (1) #define ISRANGE(val, lo, hi) ((lo <= val) && (val < hi)) int main() { ll ans, r, g, b, n; ans = 0; cin >> r >> g >> b >> n; for (int i = 0; i * r <= n; i++) { for (int j = 0; j * g + i * r <= n; j++) { if ((n - (j * g + i * r)) % b == 0) ans++; } } cout << ans << endl; return 0; }
replace
19
23
19
21
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> #include <string> using namespace std; int 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 <iostream> #include <string> using namespace std; int 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++; } } } } */ for (int j = 0; j <= N / G; j++) { for (int k = 0; k <= N / B; k++) { if ((((N - (j * G + k * B)) % R) == 0) && (N - (j * G + k * B)) >= 0) { count++; } } } cout << count << endl; return 0; }
replace
11
17
11
31
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> typedef char SINT8; typedef unsigned char UINT8; typedef short SINT16; typedef unsigned short UINT16; typedef int SINT32; typedef unsigned int UINT32; typedef long long SINT64; typedef unsigned long long UINT64; typedef double DOUBLE; #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(a) ((a) > (0) ? (a) : -(a)) #define rep(i, a, b) for (int(i) = int(a); (i) < int(b); (i)++) #define INF 1000000001 #define MOD 1000000007 #define INF64 1000000000000000001 #define F first #define S second #define Pii pair<SINT32, SINT32> #define Pll pair<SINT64, SINT64> using namespace std; int main() { SINT32 A, B, C, N; SINT32 ans = 0; cin >> A >> B >> C >> N; rep(i, 0, N / A + 1) { rep(j, 0, (N - i * A) / B + 1) { rep(k, 0, (N - i * A - j * B) / C + 1) { if ((A * i + B * j + C * k) == N) { ans++; } } } } cout << ans << endl; return 0; } // sort(DATA.begin(),DATA.end()); // sort(DATA.begin(),DATA.end(),std::greater<SINT32>()); // __gcd(ANS,DATA[i]); // // DATA.emplace_back(BUF); //後ろに追加 // DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end()); // //ソート後に使用 // DATA.insert(DATA.begin() + X, 0); //X番目の要素に0を挿入 // vector<vector<SINT32>> DP(N,vector<SINT32>(3)); //2次元配列 /* SINT32 M = 3; vector<pair<SINT32,SINT32>> DATA2(M); for (SINT32 i = 0; i < M; i++) { cin >> DATA2[i].first; cin >> DATA2[i].second; } sort(DATA2.begin(),DATA2.end()); cout << DATA2[0].first << endl; cout << DATA2[0].second << endl; */ // vector<pair<int,pair<int,int>>> DATA(M); // cin >> DATA[i].first; // cin >> DATA[i].second.first; // cin >> DATA[i].second.second; // APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - //ADATA.begin(); //key以上を探す BPOSI = //lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin(); /* 文字列回転 string N; cin >> N; N = N[N.length()-1] + N.substr(0,N.length()-1); */ /* 文字列合成 string N,M; cin >> N >> M; SINT64 ans = 0; ans = stoi(N+M); */ /* //ワーシャルフロイド vector<vector<SINT32>> dist(N,vector<SINT32>(N)); rep(i,0,N) { rep(j,0,N) { if (i != j) { dist[i][j] = INF; } } } rep(k,0,N) { rep(i,0,N) { rep(j,0,N) { dist[i][j] = MIN(dist[i][j], dist[i][k]+dist[k][j]); } } } */ /* SET コンテナ set<SINT32> DATA; for (SINT32 i = 0; i < N; i++) { SINT32 buf; cin >> buf; DATA.insert(buf); } //全表示 set<string>::iterator it; // イテレータを用意 for(it = DATA.begin(); it != DATA.end(); it++) { cout << *it << endl; } //N番目を一部表示 set<string>::iterator it; // イテレータを用意 it = DATA.begin(); rep (i,0,N) { it++; } cout << *it << endl; */ /* map map<string,SINT32> mp; SINT32 N = 0; SINT32 mx = 0; cin >> N; for (SINT32 i = 0; i < N; i++) { string s; cin >> s; mp[s]++; } for(auto it=mp.begin();it!=mp.end();it++) { mx=max(mx,it->second); } */ /* //順列全表示 //sortしてからでないと全列挙にならない sort(DATA.begin(),DATA.end()); do { cout << buf << endl; rep(i,0,R) { cout << DATA[i] << " "; } cout << endl; } while (next_permutation(DATA.begin(),DATA.end())); */
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> typedef char SINT8; typedef unsigned char UINT8; typedef short SINT16; typedef unsigned short UINT16; typedef int SINT32; typedef unsigned int UINT32; typedef long long SINT64; typedef unsigned long long UINT64; typedef double DOUBLE; #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(a) ((a) > (0) ? (a) : -(a)) #define rep(i, a, b) for (int(i) = int(a); (i) < int(b); (i)++) #define INF 1000000001 #define MOD 1000000007 #define INF64 1000000000000000001 #define F first #define S second #define Pii pair<SINT32, SINT32> #define Pll pair<SINT64, SINT64> using namespace std; int main() { SINT32 A, B, C, N; SINT32 ans = 0; cin >> A >> B >> C >> N; rep(i, 0, N / A + 1) { rep(j, 0, (N - i * A) / B + 1) { if (((N - A * i - B * j) % C) == 0) { ans++; } } } cout << ans << endl; return 0; } // sort(DATA.begin(),DATA.end()); // sort(DATA.begin(),DATA.end(),std::greater<SINT32>()); // __gcd(ANS,DATA[i]); // // DATA.emplace_back(BUF); //後ろに追加 // DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end()); // //ソート後に使用 // DATA.insert(DATA.begin() + X, 0); //X番目の要素に0を挿入 // vector<vector<SINT32>> DP(N,vector<SINT32>(3)); //2次元配列 /* SINT32 M = 3; vector<pair<SINT32,SINT32>> DATA2(M); for (SINT32 i = 0; i < M; i++) { cin >> DATA2[i].first; cin >> DATA2[i].second; } sort(DATA2.begin(),DATA2.end()); cout << DATA2[0].first << endl; cout << DATA2[0].second << endl; */ // vector<pair<int,pair<int,int>>> DATA(M); // cin >> DATA[i].first; // cin >> DATA[i].second.first; // cin >> DATA[i].second.second; // APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - //ADATA.begin(); //key以上を探す BPOSI = //lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin(); /* 文字列回転 string N; cin >> N; N = N[N.length()-1] + N.substr(0,N.length()-1); */ /* 文字列合成 string N,M; cin >> N >> M; SINT64 ans = 0; ans = stoi(N+M); */ /* //ワーシャルフロイド vector<vector<SINT32>> dist(N,vector<SINT32>(N)); rep(i,0,N) { rep(j,0,N) { if (i != j) { dist[i][j] = INF; } } } rep(k,0,N) { rep(i,0,N) { rep(j,0,N) { dist[i][j] = MIN(dist[i][j], dist[i][k]+dist[k][j]); } } } */ /* SET コンテナ set<SINT32> DATA; for (SINT32 i = 0; i < N; i++) { SINT32 buf; cin >> buf; DATA.insert(buf); } //全表示 set<string>::iterator it; // イテレータを用意 for(it = DATA.begin(); it != DATA.end(); it++) { cout << *it << endl; } //N番目を一部表示 set<string>::iterator it; // イテレータを用意 it = DATA.begin(); rep (i,0,N) { it++; } cout << *it << endl; */ /* map map<string,SINT32> mp; SINT32 N = 0; SINT32 mx = 0; cin >> N; for (SINT32 i = 0; i < N; i++) { string s; cin >> s; mp[s]++; } for(auto it=mp.begin();it!=mp.end();it++) { mx=max(mx,it->second); } */ /* //順列全表示 //sortしてからでないと全列挙にならない sort(DATA.begin(),DATA.end()); do { cout << buf << endl; rep(i,0,R) { cout << DATA[i] << " "; } cout << endl; } while (next_permutation(DATA.begin(),DATA.end())); */
replace
44
48
44
46
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> #include <string> 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 + g + b == N) count++; } } } cout << count << endl; return 0; }
#include <iostream> #include <string> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int count = 0; for (int r = 0; r * R <= N; r++) { for (int g = 0; g * G <= N - r * R; g++) { if ((N - r * R - g * G) % B == 0) count++; } } cout << count << endl; return 0; }
replace
8
14
8
12
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define len(x) (ll)(x).length() using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const ll INFS = 1e18; const int MOD = INF + 7; const int di[] = {-1, 0, 1, 0}; const int dj[] = {0, -1, 0, 1}; 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; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define len(x) (ll)(x).length() using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const ll INFS = 1e18; const int MOD = INF + 7; const int di[] = {-1, 0, 1, 0}; const int dj[] = {0, -1, 0, 1}; 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) >= 0) ans++; } } cout << ans << endl; }
replace
19
23
19
21
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; int main(void) { int N, A; int T[3]; cin >> T[0] >> T[1] >> T[2] >> N; A = 0; sort(T, T + 3); reverse(T, T + 3); for (int i = 0; i <= N / T[0]; i++) { for (int j = 0; j <= (N - i * T[0]) / T[1]; j++) { for (int t = 0; t <= (N - i * T[0] - j * T[1]) / T[2]; t++) { if (T[0] * i + T[1] * j + T[2] * t == N) { A = A + 1; } } } } cout << A << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main(void) { int N, A; int T[3]; cin >> T[0] >> T[1] >> T[2] >> N; A = 0; sort(T, T + 3); reverse(T, T + 3); for (int i = 0; i <= N / T[0]; i++) { for (int j = 0; j <= (N - i * T[0]) / T[1]; j++) { if ((N - T[0] * i - T[1] * j) % T[2] == 0) { A = A + 1; } } } cout << A << endl; return 0; }
replace
14
18
14
17
TLE
p03048
C++
Time Limit Exceeded
#define _USE_MATH_DEFINES // M_PI #include <bits/stdc++.h> #include <cmath> using namespace std; using ll = long long; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) #define rREP(i, a, n) for (int(i) = (n)-1; (i) >= (a); --(i)) #define all(x) (x).begin(), (x).end() #define out(y, x, h, w) (y) < 0 || (x) < 0 || (y) >= (h) || (x) >= (w) constexpr int INF = 2147483647; constexpr ll mod = 1000000007; 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; } inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } int main() { init(); int r, g, b, N; cin >> r >> g >> b >> N; int ans = 0; for (int i = 0; i < N + 1; i += r) { for (int j = 0; j < N + 1; j += g) { for (int k = 0; k < N + 1; k += b) { if (i + j + k == N) ++ans; } } } cout << ans << "\n"; return 0; }
#define _USE_MATH_DEFINES // M_PI #include <bits/stdc++.h> #include <cmath> using namespace std; using ll = long long; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) #define rREP(i, a, n) for (int(i) = (n)-1; (i) >= (a); --(i)) #define all(x) (x).begin(), (x).end() #define out(y, x, h, w) (y) < 0 || (x) < 0 || (y) >= (h) || (x) >= (w) constexpr int INF = 2147483647; constexpr ll mod = 1000000007; 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; } inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } int main() { init(); int r, g, b, N; cin >> r >> g >> b >> N; int ans = 0; for (int i = 0; i < N + 1; i += r) { for (int j = 0; j < N + 1; j += g) { if (N - i - j < 0) continue; if ((N - i - j) % b == 0) ++ans; } } cout << ans << "\n"; return 0; }
replace
42
46
42
46
TLE
p03048
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; int main(void) { int r, g, b, k; cin >> r >> g >> b >> k; int temp1, temp2; int num = 0; for (int x = 0; x < k + 1; x++) { if (x * r > k) continue; temp1 = k - r * x; for (int y = 0; y < temp1 + 1; y++) { if (y * g > temp1) continue; temp2 = temp1 - g * y; for (int z = 0; z < temp2 + 1; z++) { if (z * b > temp2) continue; if (temp2 == z * b) { // cout << "x:"<<x<< " y:" << y << " z:" << z << endl; // cout << '\n'; num++; } } } } cout << num << endl; }
#include <iostream> #include <vector> using namespace std; int main(void) { int r, g, b, k; cin >> r >> g >> b >> k; int temp1, temp2; int num = 0; for (int x = 0; x < k + 1; x++) { if (x * r > k) continue; temp1 = k - r * x; for (int y = 0; y < temp1 + 1; y++) { if (y * g > temp1) continue; temp2 = temp1 - g * y; if (temp2 % b == 0) { // cout << "x:"<<x<< " y:" << y << " z:" << z << endl; // cout << '\n'; num++; } } } cout << num << endl; }
replace
18
26
18
22
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define pie 3.141592653589793238462643383279 #define mod 998244353 #define inf 10000000000000007 #define all(vec) vec.begin(), vec.end() #define ggr \ getchar(); \ getchar(); \ return 0; #define ll long long int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } bool prime(int x) { for (int i = 2; i <= sqrt(x); i++) { if (x % i == 0) return false; } return true; } int kai(int x) { if (x == 1) return 1; return kai(x - 1) * x; } int mod_pow(int x, int y, int moder) { int res = 1; while (y > 0) { if (y & 1) res = res * x % moder; x = x * x % moder; y >>= 1; } return res; } int r, g, b, n; int ans; signed main() { cin >> r >> g >> b >> n; for (int i = 0; i <= min(g, n); i++) { for (int j = 0; j <= min(b, n); i++) { if (n - i - j <= r) ans++; } } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define pie 3.141592653589793238462643383279 #define mod 998244353 #define inf 10000000000000007 #define all(vec) vec.begin(), vec.end() #define ggr \ getchar(); \ getchar(); \ return 0; #define ll long long int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } bool prime(int x) { for (int i = 2; i <= sqrt(x); i++) { if (x % i == 0) return false; } return true; } int kai(int x) { if (x == 1) return 1; return kai(x - 1) * x; } int mod_pow(int x, int y, int moder) { int res = 1; while (y > 0) { if (y & 1) res = res * x % moder; x = x * x % moder; y >>= 1; } return res; } int r, g, b, n; int ans; signed main() { cin >> r >> g >> b >> n; for (int i = 0; i <= n / g; i++) { for (int j = 0; j <= n / b; j++) { if (i * g + j * b <= n && (n - i * g - j * b) % r == 0) ans++; } } cout << ans << endl; }
replace
57
60
57
60
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdlib.h> #include <string.h> #include <time.h> #include <vector> using namespace std; int main(void) { long long int R, G, B, N; long long int ans = 0; cin >> R >> G >> B >> N; 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 + j * G + k * B == N) ans++; cout << ans << endl; return 0; }
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdlib.h> #include <string.h> #include <time.h> #include <vector> using namespace std; int main(void) { long long int R, G, B, N; long long int ans = 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 && (N - i * R - j * G) % B == 0) ans++; cout << ans << endl; return 0; }
replace
20
23
20
22
TLE
p03048
C++
Time Limit Exceeded
#ifdef __GNUC__ #include <bits/stdc++.h> #endif // __GNUC_ int main() { int R, G, B, N; std::cin >> R >> G >> B >> N; int ans = 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) ++ans; std::cout << ans << std::endl; }
#ifdef __GNUC__ #include <bits/stdc++.h> #endif // __GNUC_ int main() { int R, G, B, N; std::cin >> R >> G >> B >> N; int ans = 0; for (int r = 0; r <= N / R; ++r) { for (int g = 0; g <= N / G; ++g) { int dif = N - r * R - g * G; if ((dif >= 0) && (dif % B == 0)) { ++ans; } } } std::cout << ans << std::endl; }
replace
9
14
9
17
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i <= (int)(n); i++) #define intll int long long const intll INF = 1e9; const int MOD = 1e9 + 7; int main() { int a, b, c, n; cin >> a >> b >> c >> n; int ans = 0; rep(i, (n / a) + 1) { rep(j, (n / b) + 1) { rep(k, (n / c) + 1) { int now = a * i + b * j + c * k; if (n == now) ans++; } } } cout << ans; }
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i <= (int)(n); i++) #define intll int long long const intll INF = 1e9; const int MOD = 1e9 + 7; int main() { int a, b, c, n; cin >> a >> b >> c >> n; int ans = 0; rep(i, 3000) { rep(j, 3000) { int now = n - (a * i + b * j); if (now % c == 0 && now >= 0) ans++; } } cout << ans; }
replace
14
21
14
19
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 count = 0; for (int r = 0; r < N / R + 1; r++) { for (int g = 0; g < (N - r * R) / G + 1; g++) { for (int b = 0; b < (N - r * R - g * G) / B + 1; b++) { int ord = N - r * R - g * G; if (ord % B != 0) { break; } else if (N == r * R + g * G + b * B) { count++; } ord /= B; } } } cout << count << endl; }
#include <bits/stdc++.h> 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 + 1; r++) { for (int g = 0; g < (N - r * R) / G + 1; g++) { int ord = N - r * R - g * G; if (ord % B == 0) { count++; } } } cout << count << endl; }
replace
9
17
9
12
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; int main() { int R, G, B, N; cin >> R >> G >> B >> N; ll 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 <algorithm> #include <iostream> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; int main() { int R, G, B, N; cin >> R >> G >> B >> N; ll 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 && (N - i * R - j * G) % B == 0) { ans++; } } } cout << ans << endl; return 0; }
replace
15
19
15
17
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); 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; }
#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); i++) { for (int j = 0; j <= ((N - i * R) / G); j++) { if ((N - i * R - j * G) % B == 0) ans++; } } cout << ans << endl; }
replace
10
14
10
12
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> #define SORT(a) sort(a.begin(), a.end()) #define RSORT(a) sort(a.rbegin(), a.rend()) #define REP(i, n) for (int i = 0; i < n; i++) #define RREP(i, n) for (int i = n; 0 <= i; i--) #define FOR(i, start, end) for (int i = start; i < end; i++) #define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step) #define RFOR(i, start, end) for (int i = start; end <= i; i--) #define ALL(a) a.begin(), a.end() #define MOD(a) a %= 1000000007 typedef long long ll; const int INF32 = 2147483647; const ll INF64 = 9223372036854775807; 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 main() { cin.tie(0); ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; REP(i, N / R + 1) { REP(j, N / G + 1) { if (R * i + G * j > N) { continue; } REP(k, N / B + 1) { int sum = R * i + G * j + B * k; if (sum == N) ans++; } } } std::cout << ans << std::endl; return 0; }
#include <algorithm> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> #define SORT(a) sort(a.begin(), a.end()) #define RSORT(a) sort(a.rbegin(), a.rend()) #define REP(i, n) for (int i = 0; i < n; i++) #define RREP(i, n) for (int i = n; 0 <= i; i--) #define FOR(i, start, end) for (int i = start; i < end; i++) #define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step) #define RFOR(i, start, end) for (int i = start; end <= i; i--) #define ALL(a) a.begin(), a.end() #define MOD(a) a %= 1000000007 typedef long long ll; const int INF32 = 2147483647; const ll INF64 = 9223372036854775807; 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 main() { cin.tie(0); ios::sync_with_stdio(false); int R, G, B, N; cin >> R >> G >> B >> N; int ans = 0; REP(i, N / R + 1) { REP(j, N / G + 1) { int k = N - (R * i + G * j); if (k % B == 0 && k >= 0) ans++; } } std::cout << ans << std::endl; return 0; }
replace
45
53
45
49
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; std::cin >> R >> G >> B >> N; int ans = 0; for (size_t i = 0; i < N + 1; i++) { for (size_t j = 0; j < N + 1; j++) { for (size_t k = 0; k < N + 1; k++) { if (R * i + B * j + G * k == N) { ans++; } else if (R * i + B * j + G * k > N) { break; } } } } std::cout << ans << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; std::cin >> R >> G >> B >> N; if (R + G + B == 3) { std::cout << (N + 2) * (N + 1) / 2 << '\n'; return 0; } int ans = 0; for (size_t i = 0; i < N + 1; i++) { for (size_t j = 0; j < N + 1; j++) { for (size_t k = 0; k < N + 1; k++) { if (R * i + B * j + G * k == N) { ans++; } else if (R * i + B * j + G * k > N) { break; } } } } std::cout << ans << '\n'; }
insert
6
6
6
11
TLE
p03048
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define printArr(harry, tam) range(tam) cout << harry[i] << " \n"[i == tam - 1]; #define range(n) for (int i = 0; i < n; i++) #define forn(x, n) for (int x = 0; x < n; x++) #define maxn "100000" #define mod "1000000007" #define md(x) ((((x) % mod) + mod) % mod) #define sc scanf #define pr printf #define fi first #define se second #define mp make_pair #define pb push_back #define prt(x) cout << (#x) << " is " << (x) << endl #define EPS 1e-9 #define INF INT_MAX #define INFd 1e9 typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef vector<int> vi; // Trace dinamico template <typename T> void trace(T a) { cout << a << "\n"; } template <typename T, typename... Args> void trace(T a, Args... args) { cout << a << " "; trace(args...); } // DP debug int recNum = 0; void prTabs() { range(recNum) cout << " "; } template <typename... Args> void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; } template <typename T> void recEnd(T a) { prTabs(); trace("->", a); recNum--; } int r, g, b, n; // vector<int> g[maxn]; int li[9000010]; int main() { sc("%d %d %d %d\n", &r, &g, &b, &n); for (int i = 0; i < 3001; i++) { for (int j = 0; j < 3001; j++) { li[i * r + j * g]++; } } int r = 0; for (int i = 0; i < 3001; i++) { int t = b * i; if (t <= n) { r += li[n - t]; } } pr("%d\n", r); return 0; }
#include <bits/stdc++.h> using namespace std; #define printArr(harry, tam) range(tam) cout << harry[i] << " \n"[i == tam - 1]; #define range(n) for (int i = 0; i < n; i++) #define forn(x, n) for (int x = 0; x < n; x++) #define maxn "100000" #define mod "1000000007" #define md(x) ((((x) % mod) + mod) % mod) #define sc scanf #define pr printf #define fi first #define se second #define mp make_pair #define pb push_back #define prt(x) cout << (#x) << " is " << (x) << endl #define EPS 1e-9 #define INF INT_MAX #define INFd 1e9 typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef vector<int> vi; // Trace dinamico template <typename T> void trace(T a) { cout << a << "\n"; } template <typename T, typename... Args> void trace(T a, Args... args) { cout << a << " "; trace(args...); } // DP debug int recNum = 0; void prTabs() { range(recNum) cout << " "; } template <typename... Args> void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; } template <typename T> void recEnd(T a) { prTabs(); trace("->", a); recNum--; } int r, g, b, n; // vector<int> g[maxn]; int li[18000010]; int main() { sc("%d %d %d %d\n", &r, &g, &b, &n); for (int i = 0; i < 3001; i++) { for (int j = 0; j < 3001; j++) { li[i * r + j * g]++; } } int r = 0; for (int i = 0; i < 3001; i++) { int t = b * i; if (t <= n) { r += li[n - t]; } } pr("%d\n", r); return 0; }
replace
46
47
46
47
0
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define mfill(x, y) memset(x, y, sizeof(x)) #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define eprintf(...) 42 #endif #define y0 y12345 #define y1 y54321 typedef unsigned long ul; typedef long long ll; // typedef pair<int, int> mpair; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m, r, g, b; cin >> r >> g >> b >> n; int cou = 0; rep(i, 3001) { if (i * r > n) break; rep(j, 3001) { if (i * r + j * g > n) break; rep(k, 3001) { if (i * r + j * g + k * b == n) { cou++; } else if (i * r + j * g + k * b > n) { break; } } } } cout << cou << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define mfill(x, y) memset(x, y, sizeof(x)) #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define eprintf(...) 42 #endif #define y0 y12345 #define y1 y54321 typedef unsigned long ul; typedef long long ll; // typedef pair<int, int> mpair; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m, r, g, b; cin >> r >> g >> b >> n; int cou = 0; rep(i, 3001) { if (i * r > n) break; rep(j, 3001) { if (i * r + j * g > n) break; for (int k = (n - i * r - j * g) / b; k < 3001; k++) { if (i * r + j * g + k * b == n) { cou++; } else if (i * r + j * g + k * b > n) { break; } } } } cout << cou << endl; return 0; }
replace
41
42
41
42
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <string> #include <vector> using namespace std; int main() { int R, G, B, N, count = 0; cin >> R >> G >> B >> N; for (int i = 0; R * i <= N; i++) { for (int j = 0; G * j <= N; j++) { for (int k = 0; B * k <= N; k++) { if (R * i + G * j + B * k == N) { count++; } } } } cout << count; return 0; }
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <string> #include <vector> using namespace std; int main() { int R, G, B, N, count = 0; cin >> R >> G >> B >> N; for (int i = 0; R * i <= N; i++) { for (int j = 0; G * j <= N; j++) { if ((N - R * i - G * j) % B == 0 && N - R * i - G * j >= 0) { count++; } } } cout << count; return 0; }
replace
20
24
20
22
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; int ans = 0; cin >> R >> G >> B >> N; 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) ans++; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; int ans = 0; cin >> R >> G >> B >> N; 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) ans++; cout << ans << endl; }
replace
10
13
10
12
TLE
p03048
C++
Time Limit Exceeded
#define _USE_MATH_DEFINES #include "bits/stdc++.h" #define rep(i, a, b) for (int i = (a); i < (b); i++) using namespace std; typedef long long int ll; typedef complex<double> com; typedef pair<ll, ll> P; const int mod = 1e9 + 7; const int MOD = 998244353; const int inf = 2e9; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; rep(i, 0, n / r + 2) rep(j, 0, n / g + 2) rep(k, 0, n / b + 2) { if (i * r + j * g + b * k == n) ans++; } printf("%d", ans); return 0; }
#define _USE_MATH_DEFINES #include "bits/stdc++.h" #define rep(i, a, b) for (int i = (a); i < (b); i++) using namespace std; typedef long long int ll; typedef complex<double> com; typedef pair<ll, ll> P; const int mod = 1e9 + 7; const int MOD = 998244353; const int inf = 2e9; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int ans = 0; rep(i, 0, n + 1) rep(j, 0, n + 1) { int k = n - i * r - j * g; if (k >= 0 && k % b == 0) ans++; } printf("%d", ans); return 0; }
replace
15
17
15
18
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (N); ++i) #define ALL(x) (x).begin(), (x).end() #define MOD 1000000007 #define PB push_back #define MP make_pair using namespace std; typedef long long ll; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll div_ceil(ll, ll); int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; int main() { int R, G, B, N; std::cin >> R >> G >> B >> N; int count = 0; REP(i, N / R + 1) { REP(j, (N - R * i) / G + 1) { REP(k, (N - R * i - G * j) / B + 1) { if (i * R + j * G + k * B == N) { count++; } } } } std::cout << count << '\n'; } ll div_ceil(ll a, ll b) { ll quotient = a / b; ll remainder = a % b; if (remainder == 0) { return quotient; } else { return quotient + 1; } }
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (N); ++i) #define ALL(x) (x).begin(), (x).end() #define MOD 1000000007 #define PB push_back #define MP make_pair using namespace std; typedef long long ll; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll div_ceil(ll, ll); int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; int main() { int R, G, B, N; std::cin >> R >> G >> B >> N; int count = 0; REP(r, N / R + 1) { REP(g, (N - R * r) / G + 1) { if ((N - R * r - G * g) % B == 0) count++; } } std::cout << count << '\n'; } ll div_ceil(ll a, ll b) { ll quotient = a / b; ll remainder = a % b; if (remainder == 0) { return quotient; } else { return quotient + 1; } }
replace
18
25
18
22
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 answer = 0; for (int r = 0; r < int(N / R) + 1; r++) { for (int g = 0; g < int(N / G) + 1; g++) { if (r * R + g * G > N) { break; } for (int b = 0; b < int(N / B) + 1; b++) { if (r * R + g * G + b * B > N) { break; } if (r * R + g * G + b * B == N) { answer++; } } } } cout << answer << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B, N; cin >> R >> G >> B >> N; int answer = 0; for (int r = 0; r < int(N / R) + 1; r++) { for (int g = 0; g < int(N / G) + 1; g++) { if (r * R + g * G > N) { break; } if ((N - r * R - g * G) % B == 0) { answer++; } } } cout << answer << endl; return 0; }
replace
13
20
13
15
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int R, G, B; cin >> R >> G >> B; int N; cin >> N; int count = 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 + j * G + i * R <= N; 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; cin >> R >> G >> B; int N; cin >> N; int count = 0; for (int i = 0; i * R <= N; i++) { for (int j = 0; j * G + i * R <= N; j++) { int sum = N - j * G - i * R; if (sum % B == 0) { count++; } } } cout << count << endl; }
replace
11
15
11
14
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <iostream> #include <limits> #include <map> #include <memory> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr long long MOD = 1000000007; int main() { int R, G, B, N; std::cin >> R >> G >> B >> N; int ans = 0; int r = N / R; for (int i = 0; i <= r; ++i) { int n = N - R * i; int g = n / G; for (int j = 0; j <= g; ++j) { int n1 = n - G * j; int b = n1 / B; for (int k = 0; k <= b; ++k) { int n2 = n1 - B * k; if (n2 == 0) { ++ans; } } } } std::cout << ans << std::endl; return 0; }
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <iostream> #include <limits> #include <map> #include <memory> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr long long MOD = 1000000007; int main() { int R, G, B, N; std::cin >> R >> G >> B >> N; int ans = 0; int r = N / R; for (int i = 0; i <= r; ++i) { int n = N - R * i; int g = n / G; for (int j = 0; j <= g; ++j) { int n1 = n - G * j; if (n1 % B == 0) ++ans; } } std::cout << ans << std::endl; return 0; }
replace
27
34
27
29
TLE
p03048
C++
Time Limit Exceeded
#define _USE_NATH_DEFINES #include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; #define EPS 1e-9 const int INF = 1050000000; const long long LINF = 1LL << 60; const ll MOD = 1e9 + 7; const int MINF = -1050000000; 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; }
#define _USE_NATH_DEFINES #include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; #define EPS 1e-9 const int INF = 1050000000; const long long LINF = 1LL << 60; const ll MOD = 1e9 + 7; const int MINF = -1050000000; 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) { if (((n - i * r - j * g) % b) == 0 && n >= (i * r + j * g)) cnt++; } } cout << cnt << endl; return 0; }
replace
43
47
43
45
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 count = 0; for (int i = 0; i <= N / R; i++) { for (int j = 0; G * j <= N - R * i; j++) { for (int k = 0; B * k <= N - R * i - G * j; k++) { int sum = i * R + j * G + k * B; if (sum == N) { count++; } } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int 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; G * j <= N - R * i; j++) { int k = N - R * i - G * j; if (k >= 0 && k % B == 0) { count++; } } } cout << count << endl; }
replace
8
13
8
11
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <numeric> #include <set> #include <string> #include <vector> using namespace std; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int counter = 0; for (size_t i = 0; i <= n / r; i++) { for (size_t j = 0; j <= n / g; j++) { for (size_t k = 0; k <= n / b; k++) { if ((i * r + j * g + k * b) == n) counter++; } } } cout << counter << endl; return 0; }
#include <algorithm> #include <iostream> #include <numeric> #include <set> #include <string> #include <vector> using namespace std; int main() { int r, g, b, n; cin >> r >> g >> b >> n; int counter = 0; for (size_t i = 0; i <= n / r; i++) { for (size_t j = 0; j <= n / g; j++) { int z = (n - (i * r + j * g)) / b; if (0 <= z && z <= (n / b) && z * b + j * g + i * r == n) counter++; } } cout << counter << endl; return 0; }
replace
15
19
15
18
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int P, Q, R, N; cin >> P >> Q >> R >> N; int count = 0; int x = N / P + 1; for (int i = 0; i < x; i++) { for (int j = 0; j < (N - P * i) / Q + 1 && i + j < N + 1; j++) { for (int k = 0; k < (N - P * i - Q * j) / R + 1 && i + j + k < N + 1; k++) { if (P * i + Q * j + R * k == N) { count++; break; } } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int P, Q, R, N; cin >> P >> Q >> R >> N; int count = 0; int x = N / P + 1; for (int i = 0; i < x; i++) { for (int j = 0; j < (N - P * i) / Q + 1 && i + j < N + 1; j++) { int B = N - P * i - Q * j; if (B % R == 0 && B >= 0) count++; } } cout << count << endl; }
replace
10
17
10
13
TLE
p03048
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i < (n); ++i) using namespace std; typedef long long ll; const ll INF = 1LL << 60; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int r, g, b, n; cin >> r >> g >> b >> n; int res = 0; for (int i = 0; i <= (n + r - 1) / r; ++i) { for (int j = 0; j <= (n + g - 1) / g; ++j) { for (int k = 0; k <= (n + b - 1) / b; ++k) { if (r * i + g * j + b * k == n) ++res; } } } cout << res << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i < (n); ++i) using namespace std; typedef long long ll; const ll INF = 1LL << 60; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int r, g, b, n; cin >> r >> g >> b >> n; int res = 0; for (int i = 0; i <= (n + r - 1) / r; ++i) { for (int j = 0; j <= (n + g - 1) / g; ++j) { if ((n - (r * i + g * j)) >= 0 && ((n - (r * i + g * j)) % b == 0)) { ++res; } } } cout << res << endl; return 0; }
replace
18
21
18
20
TLE
p03048
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <functional> #include <iostream> #include <map> #include <numeric> #include <sstream> #include <stdio.h> #include <vector> #define FORi(N) for (int i = 0; i < N; ++i) #define FORj(N) for (int j = 0; j < N; ++j) using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; ll gcd(ll m, ll n) { if (n == 0) return abs(m); return (gcd(n, m % n)); } void putYN(bool b) { if (b) { cout << "YES" << endl; } else { cout << "NO" << endl; } } int main() { ll R, G, B, N; cin >> R >> G >> B >> N; ll num = 0; for (int r = 0; r <= N; r += R) { for (int g = 0; g <= N; g += G) { if (r + g > N) break; for (int b = 0; b <= N; b += B) { if (r + g + b > N) break; if (r + g + b == N) num++; } } } cout << num << endl; return 0; }
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <functional> #include <iostream> #include <map> #include <numeric> #include <sstream> #include <stdio.h> #include <vector> #define FORi(N) for (int i = 0; i < N; ++i) #define FORj(N) for (int j = 0; j < N; ++j) using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; ll gcd(ll m, ll n) { if (n == 0) return abs(m); return (gcd(n, m % n)); } void putYN(bool b) { if (b) { cout << "YES" << endl; } else { cout << "NO" << endl; } } int main() { ll R, G, B, N; cin >> R >> G >> B >> N; ll num = 0; for (int r = 0; r <= N; r += R) { for (int g = 0; g <= N; g += G) { if (r + g > N) break; if ((N - (r + g)) % B == 0) num++; /*for(int b=0;b<=N;b+=B){ if(r+g+b>N)break; if(r+g+b==N)num++; }*/ } } cout << num << endl; return 0; }
replace
38
44
38
44
TLE