結果
| 問題 | No.1595 The Final Digit | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-07-14 15:44:35 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 361 bytes | 
| コンパイル時間 | 690 ms | 
| コンパイル使用メモリ | 97,000 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-22 11:44:26 | 
| 合計ジャッジ時間 | 1,499 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
import std.stdio;
import std.conv;
import std.string;
void main(){
	auto l=readln.split.to!(long[]);
	auto k=l[3];
	auto a=new int[1000];
	auto x=l[0]%10*100+l[1]%10*10+l[2]%10;
	auto n=4;
	a[x]=n;
	while(n<k){
		x*=10;
		x+=(x/1000+x/100+x/10)%10;
		x%=1000;
		n+=1;
		if(a[x]!=int.init){
			k=n+(k-n)%(n-a[x]);
		}
		a[x]=n;
	}
	writeln((x/100+x/10+x)%10);
}
            
            
            
        