結果

問題 No.313 π
ユーザー konjo_p
提出日時 2015-12-07 00:56:17
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 57,972 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 17:10:50
合計ジャッジ時間 2,481 ms
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
const ll correct = 2122389473;

ll p = (1LL << 31) -1;
ll b = (1LL << 19) -1;

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