結果

問題 No.1486 ロボット
ユーザー yansi819
提出日時 2024-03-22 10:37:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 4,040 ms
コンパイル使用メモリ 251,308 KB
最終ジャッジ日時 2025-02-20 10:53:52
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

int calc(int a, int b, int c, int d, int e) {
  int cnt = 0;
  for (int i = 0; i < e; i++) {
    if (i % (a + b) < a && i % (c + d) < c) cnt++;
  }
  return cnt;
}

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int lim = (a + b) * (c + d);
  int ans = 0;
  if (e > lim) {
    int ans0 = calc(a, b, c, d, lim);
    ans += ans0 * (e / lim);
    e %= lim;
  }
  ans += calc(a, b, c, d, e);
  cout << ans << endl;
  return 0;
}
0