結果

問題 No.313 π
ユーザー konjo_pkonjo_p
提出日時 2015-12-07 01:00:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 657 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 59,840 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-12 18:44:36
合計ジャッジ時間 2,619 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,348 KB
testcase_01 AC 34 ms
4,348 KB
testcase_02 AC 9 ms
4,348 KB
testcase_03 AC 9 ms
4,352 KB
testcase_04 AC 9 ms
4,352 KB
testcase_05 AC 9 ms
4,348 KB
testcase_06 AC 9 ms
4,348 KB
testcase_07 AC 9 ms
4,348 KB
testcase_08 AC 9 ms
4,352 KB
testcase_09 AC 9 ms
4,348 KB
testcase_10 AC 34 ms
4,348 KB
testcase_11 AC 34 ms
4,348 KB
testcase_12 AC 34 ms
4,348 KB
testcase_13 AC 34 ms
4,348 KB
testcase_14 AC 35 ms
4,348 KB
testcase_15 AC 34 ms
4,348 KB
testcase_16 AC 34 ms
4,352 KB
testcase_17 AC 34 ms
4,348 KB
testcase_18 AC 33 ms
4,352 KB
testcase_19 AC 23 ms
4,352 KB
testcase_20 AC 10 ms
4,352 KB
testcase_21 AC 23 ms
4,348 KB
testcase_22 AC 31 ms
4,476 KB
testcase_23 AC 25 ms
4,348 KB
testcase_24 AC 15 ms
4,352 KB
testcase_25 AC 14 ms
4,352 KB
testcase_26 AC 29 ms
4,348 KB
testcase_27 AC 28 ms
4,352 KB
testcase_28 AC 12 ms
4,348 KB
testcase_29 AC 22 ms
4,348 KB
testcase_30 AC 16 ms
4,352 KB
testcase_31 AC 13 ms
4,352 KB
testcase_32 AC 31 ms
4,352 KB
testcase_33 AC 21 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

typedef long long ll;
//const ll correct = 2122389473;
const ll correct = 1590773764;

ll p = (1LL << 31) -1;
//ll b = (1LL << 19) -1;
ll b = 1e9+7;

int main() {
	string s;
	ll hash = 0;
	cin >> s;
	for(int i = s.size()-1; i >= 0; i--) {
		if(s[i] != '.')
			hash = (hash * b + s[i]-'0') % p;
	}
	ll a = 1;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] != '.') {
			ll tmp = (hash - (s[i]-'0') * a + p) % p;
			for(int j = 0; j < 10; j++) {
				if(correct == (tmp + j * a) % p) {
					cout << s[i] << " " << j << endl;
					return 0;
				}
			}
			a = (a * b) % p;
		}
	}
}
0