結果

問題 No.1486 ロボット
コンテスト
ユーザー bonKotsu
提出日時 2021-04-28 23:33:08
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 516 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 867 ms
コンパイル使用メモリ 183,988 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2026-03-29 14:19:49
合計ジャッジ時間 1,668 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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