結果
問題 |
No.1486 ロボット
|
ユーザー |
![]() |
提出日時 | 2021-04-30 12:43:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 1,124 bytes |
コンパイル時間 | 1,701 ms |
コンパイル使用メモリ | 166,288 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 10:37:57 |
合計ジャッジ時間 | 2,396 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; uint64_t gcd(const uint64_t a, const uint64_t b) { return b == 0 ? a : gcd(b, a % b); } int main() { uint64_t E; uint32_t A, B, C, D; cin >> A >> B >> C >> D >> E; const uint32_t work_rest_1 = A + B; const uint32_t work_rest_2 = C + D; const uint64_t work_lcm = work_rest_1 * work_rest_2 / gcd(work_rest_1, work_rest_2); uint64_t count = 0; if (work_lcm < E) { for (uint64_t t = 0; t < work_lcm; ++t) { bool work_1 = (t % work_rest_1 < A); bool work_2 = (t % work_rest_2 < C); if (work_1 && work_2) { ++count; } } count *= E / work_lcm; const uint64_t mod_E_lcm = E % work_lcm; for (uint64_t t = 0; t < mod_E_lcm; ++t) { bool work_1 = (t % work_rest_1 < A); bool work_2 = (t % work_rest_2 < C); if (work_1 && work_2) { ++count; } } } else { for (uint64_t t = 0; t < E; ++t) { bool work_1 = (t % work_rest_1 < A); bool work_2 = (t % work_rest_2 < C); if (work_1 && work_2) { ++count; } } } cout << count << endl; }