結果

問題 No.1595 The Final Digit
ユーザー ransewhaleransewhale
提出日時 2021-07-10 00:38:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,089 bytes
コンパイル時間 991 ms
コンパイル使用メモリ 78,468 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 11:58:34
合計ジャッジ時間 1,735 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 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,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 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 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int db[1111][64];

int main(void){
	int i,j,p,q,r;
	ll k;
	for(i=0; i<1000; ++i){
		p = i/100; q = (i%100)/10; r = i%10;
		db[i][0] = q*100+r*10+(p+q+r)%10;
		// std::cout << p << " " << q << " " << r << " " << db[i][0] << std::endl;
		// std::cout << i << " " << db[i][0] << std::endl;
	}
	for(j=0; j<62; ++j){
		for(i=0; i<1000; ++i){
			db[i][j+1] = db[db[i][j]][j];
		}
	}
	std::cin >> p >> q >> r; p %= 10; q %= 10; r %= 10;
	i = p*100+q*10+r;
	// std::cout << i << std::endl;
	std::cin >> k; --k;
	for(j=0; j<62; ++j){
		if(k%2){
			// std::cout << i << " " << j << " " << db[i][j] << std::endl;
			i = db[i][j];
		}
		k /= 2;
	}
	std::cout << (i/100) << std::endl;
	return 0;
}
0