提出 #8801976


ソースコード 拡げる

#include <bits/stdc++.h>

using namespace std;

long long Q[1005];
int top = -1;

int main() {
    long long n, x, ans = 0;
    cin >> n >> x;
    if(n - x > x) {
        Q[++top] = x;
        Q[++top] = n - x;
        Q[++top] = x;
        ans += n;
    }
    else {
        Q[++top] = x;
        Q[++top] = n - x;
        ans += n;
    }
    while(Q[top]) {
        long long k = Q[top - 1] / Q[top];
        ans += 2 * k * Q[top];
        Q[top + 1] = Q[top - 1] - k * Q[top];
        top ++ ;
    }
    ans -= Q[top - 1];
    printf("%lld\n", ans);
    return 0;
}

//21:56:00
//思考时间有点长。对全新模型的建立/理解能力不够强。

提出情報

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

ジャッジ結果

セット名 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 KB
01-02.txt AC 1 ms 256 KB
01-03.txt AC 1 ms 256 KB
01-04.txt AC 1 ms 256 KB
01-05.txt AC 1 ms 256 KB
01-06.txt AC 1 ms 256 KB
01-07.txt AC 1 ms 256 KB
01-08.txt AC 1 ms 256 KB
01-09.txt AC 1 ms 256 KB
02-01.txt AC 1 ms 256 KB
02-02.txt AC 1 ms 256 KB
02-03.txt AC 1 ms 256 KB
02-04.txt AC 1 ms 256 KB
02-05.txt AC 1 ms 256 KB
02-06.txt AC 1 ms 256 KB
02-07.txt AC 1 ms 256 KB
02-08.txt AC 1 ms 256 KB
02-09.txt AC 1 ms 256 KB
sample-01.txt AC 1 ms 256 KB