結果

問題 No.1595 The Final Digit
ユーザー pockynypockyny
提出日時 2021-07-09 22:29:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,023 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 72,764 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 09:44:01
合計ジャッジ時間 1,547 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:12:60: 警告: narrowing conversion of ‘(((i + j) + l) % 10)’ from ‘ll’ {aka ‘long long int’} to ‘int’ [-Wnarrowing]
   12 |             for(l=0;l<10;l++) dp[0][i][j][l] = {(i + j + l)%10,{i,j}};
      |                                                 ~~~~~~~~~~~^~~

ソースコード

diff #

#include <iostream>

using namespace std;
typedef pair<int,pair<int,int>> piii;
typedef long long ll;
piii dp[70][10][10][10];
int main(){
    ll i,j,l,m,p,q,r,k; cin >> p >> q >> r >> k;
    p %= 10; q %= 10; r %= 10;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            for(l=0;l<10;l++) dp[0][i][j][l] = {(i + j + l)%10,{i,j}};
        }
    }
    for(i=1;i<=60;i++){
        for(j=0;j<10;j++){
            for(l=0;l<10;l++){
                for(m=0;m<10;m++){
                    piii w = dp[i - 1][j][l][m];
                    int x = w.first,y = w.second.first,z = w.second.second;
                    dp[i][j][l][m] = dp[i - 1][x][y][z];
                }
            }
        }
    }
    k -= 3;
    for(i=60;i>=0;i--){
        if(k>=(1LL<<i)){
            //cout << i << endl;
            piii w = dp[i][r][q][p];
            r = w.first,q = w.second.first,p = w.second.second; 
            //cout << r << " " << q << " " << p << endl;
            k -= (1LL<<i);
        }
    }
    cout << r << endl;
}
0