結果

問題 No.1486 ロボット
ユーザー bonKotsu
提出日時 2021-04-28 23:33:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 516 bytes
コンパイル時間 1,282 ms
コンパイル使用メモリ 166,684 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 22:50:47
合計ジャッジ時間 2,148 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

}
0