結果
問題 |
No.1595 The Final Digit
|
ユーザー |
|
提出日時 | 2021-07-10 02:11:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 522 bytes |
コンパイル時間 | 1,742 ms |
コンパイル使用メモリ | 173,632 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 21:11:28 |
合計ジャッジ時間 | 2,438 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; void powmat(vector<vector<int>> &a,int n){ auto b = a; } int main(){ int p,q,r; ll k; cin >> p >> q >> r >> k; p %= 10; q %= 10; r %= 10; k --; vector<int> res = {p,q,r,(p+q+r)%10}; int j= res.size()-3; while(res[0]!=res[j] || res[1]!=res[j+1] || res[2]!=res[j+2]) { res.push_back( (res[j] + res[j+1] + res[j+2])%10); j = res.size()-3; } cout << res[ k%(res.size()-3) ] << endl; }