結果

問題 No.1486 ロボット
ユーザー fukafukatani
提出日時 2021-04-23 21:47:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 834 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 100,780 KB
最終ジャッジ日時 2025-01-20 23:45:40
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
#include <vector>

#define ALL(obj) (obj).begin()(obj).end()
#define DEBUG(x) cerr << #x << " = " << x << endl
#define ll long long

using namespace std;

int main() {
  ll a;
  ll b;
  ll c;
  ll d;
  ll e;
  std::cin >> a >> b >> c >> d >> e;

  const ll both = (a + b) * (c + d);
  ll count = 0;
  for (ll i = 0; i < both; ++i) {
    const bool ok1 = (i % (a + b)) < a;
    const bool ok2 = (i % (c + d)) < c;
    if (ok1 && ok2) {
      count += 1;
    }
  }
  ll ans = (e / both) * count;
  e %= both;
  for (ll i = 0; i < e; ++i) {
    const bool ok1 = (i % (a + b)) < a;
    const bool ok2 = (i % (c + d)) < c;
    if (ok1 && ok2) {
      ans += 1;
    }
  }
  std::cout << ans << std::endl;
}
0