結果

問題 No.747 循環小数N桁目 Hard
ユーザー potoooooooo
提出日時 2018-12-15 01:56:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 168,868 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-25 05:40:55
合計ジャッジ時間 4,514 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 120
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	string s = "142857";
	string sn, sk; cin >> sn >> sk;
	int n = 0; int k = (sk[sk.size()-1] - '0') % 2;
	for (int i = 0; i < (int) sn.size(); i++) {
		n = (n * 10 + (sn[i] - '0')) % 6;	
	}
	int ans[2][6] = {{2, 7, 5, 7, 2, 4}, {2, 8, 5, 7, 1, 4}};
	cout << ans[k][(n+5)%6] << endl;
	return 0;
}
0