結果

問題 No.1595 The Final Digit
ユーザー ktr216ktr216
提出日時 2021-07-09 21:47:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 163,908 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 08:26:43
合計ジャッジ時間 2,474 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;

typedef long long ll;

int main() {
    int p, q, r;
    ll K;
    cin >> p >> q >> r >> K;
    p %= 10;
    q %= 10;
    r %= 10;
    int a[10][10][10];
    rep(i, 0, 10) rep(j, 0, 10) rep(k, 0, 10) a[i][j][k] = -1;
    for (ll i = 1; i < K; i++) {
        if (a[p][q][r] == -1) {
            a[p][q][r] = i;
        } else {
            K = (K - i) % (i - a[p][q][r]) + i;
        }
        p = (p + q + r) % 10;
        swap(p, q);
        swap(q, r);
        //cout << p << q << r << endl;
    }
    cout << p << endl;
}
0