提出 #3218003


ソースコード 拡げる

#include <iostream>
using namespace std;
using ll = long long;

// 辺の長さがA, Bの平行四辺形内での軌道の長さ
ll reflect(ll A, ll B) {
    if (A > B) swap(A, B);

    ll ref = B / A;
    if (B % A == 0) {
        return (ref * 2 - 1) * A;
    } else {
        return ref * 2 * A + reflect(B % A, A);
    }
}

int main() {
    ll N, X;
    cin >> N >> X;

    cout << N + reflect(X, N - X) << endl;
    return 0;
}

提出情報

提出日時
問題 B - Mysterious Light
ユーザ Tiramister
言語 C++14 (GCC 5.4.1)
得点 500
コード長 456 Byte
結果 AC
実行時間 1 ms
メモリ 256 KiB

ジャッジ結果

セット名 Sample Subtask All
得点 / 配点 0 / 0 300 / 300 200 / 200
結果
AC × 1
AC × 10
AC × 20
セット名 テストケース
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 1 ms 256 KiB
01-02.txt AC 1 ms 256 KiB
01-03.txt AC 1 ms 256 KiB
01-04.txt AC 1 ms 256 KiB
01-05.txt AC 1 ms 256 KiB
01-06.txt AC 1 ms 256 KiB
01-07.txt AC 1 ms 256 KiB
01-08.txt AC 1 ms 256 KiB
01-09.txt AC 1 ms 256 KiB
02-01.txt AC 1 ms 256 KiB
02-02.txt AC 1 ms 256 KiB
02-03.txt AC 1 ms 256 KiB
02-04.txt AC 1 ms 256 KiB
02-05.txt AC 1 ms 256 KiB
02-06.txt AC 1 ms 256 KiB
02-07.txt AC 1 ms 256 KiB
02-08.txt AC 1 ms 256 KiB
02-09.txt AC 1 ms 256 KiB
sample-01.txt AC 1 ms 256 KiB