結果
問題 | No.1486 ロボット |
ユーザー |
|
提出日時 | 2021-04-28 23:37:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 516 bytes |
コンパイル時間 | 1,258 ms |
コンパイル使用メモリ | 165,520 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 22:55:27 |
合計ジャッジ時間 | 2,210 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair<int, int> int gcd(int a, int b) { return a%b ? gcd(b, a%b) : b; } int main() { int a, b, c, d, e; cin >> a >> b >> c >> d >> e; int g = gcd(a+b, c+d); int l = (a+b)/g*(c+d); int ans = 0; int cnt = 0; rep(i, l) { if (i%(a+b)<a && i%(c+d)<c) cnt++; } ans = e/l * cnt; e %= l; rep(i, e) { if (i%(a+b)<a && i%(c+d)<c) ans++; } cout << ans << endl; }