提出 #43295464
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
i64 ans;
void calc(i64 n, i64 x) {
if (n % x == 0) return ans += n * 2 - x, void();
ans += (n - n % x) * 2; calc(x, n % x);
}
int main(void) {
i64 n, x; cin >> n >> x;
ans = n; n -= x; calc(max(n, x), min(n, x));
cout << ans << "\n";
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | B - Mysterious Light |
| ユーザ | james1BadCreeper |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 500 |
| コード長 | 360 Byte |
| 結果 | AC |
| 実行時間 | 5 ms |
| メモリ | 3540 KiB |
ジャッジ結果
| セット名 | Sample | Subtask | All | ||||||
|---|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | 200 / 200 | ||||||
| 結果 |
|
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample-01.txt |
| Subtask | sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt |
| All | sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, sample-01.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01-01.txt | AC | 5 ms | 3540 KiB |
| 01-02.txt | AC | 2 ms | 3540 KiB |
| 01-03.txt | AC | 2 ms | 3540 KiB |
| 01-04.txt | AC | 2 ms | 3540 KiB |
| 01-05.txt | AC | 2 ms | 3484 KiB |
| 01-06.txt | AC | 3 ms | 3540 KiB |
| 01-07.txt | AC | 1 ms | 3480 KiB |
| 01-08.txt | AC | 2 ms | 3368 KiB |
| 01-09.txt | AC | 2 ms | 3476 KiB |
| 02-01.txt | AC | 2 ms | 3416 KiB |
| 02-02.txt | AC | 2 ms | 3476 KiB |
| 02-03.txt | AC | 2 ms | 3480 KiB |
| 02-04.txt | AC | 2 ms | 3352 KiB |
| 02-05.txt | AC | 2 ms | 3312 KiB |
| 02-06.txt | AC | 2 ms | 3472 KiB |
| 02-07.txt | AC | 2 ms | 3420 KiB |
| 02-08.txt | AC | 2 ms | 3540 KiB |
| 02-09.txt | AC | 2 ms | 3312 KiB |
| sample-01.txt | AC | 2 ms | 3524 KiB |