結果
| 問題 | No.1595 The Final Digit | 
| コンテスト | |
| ユーザー |  cureskol | 
| 提出日時 | 2021-07-09 21:29:44 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 387 bytes | 
| コンパイル時間 | 1,637 ms | 
| コンパイル使用メモリ | 165,528 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-01 15:15:44 | 
| 合計ジャッジ時間 | 2,380 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
using ll=long long;
ll D[10][10][10];
int main(){
  ll p,q,r,k;cin>>p>>q>>r>>k;
  p%=10,q%=10,r%=10;
  k-=3;
  while(k--){
    int now=(p+q+r)%10;
    if(D[q][r][now]){
      k%=(D[q][r][now]-k);
    }
    D[q][r][now]=k;
    p=q;q=r;r=now;
  }
  cout<<r<<endl;
}
            
            
            
        