結果
| 問題 | 
                            No.1312 Snake Eyes
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-12-09 00:34:12 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,280 bytes | 
| コンパイル時間 | 871 ms | 
| コンパイル使用メモリ | 92,908 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-18 22:20:09 | 
| 合計ジャッジ時間 | 3,175 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 3 | 
| other | WA * 85 | 
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long n;
bool solve(long long x, long long y, long long z) {
	long long co = 0;
	long long now = 1;
	for (long long i = 0; i < z; i++) {
		co += now * y;
		if (100000000000000000 / now < x) {
			return true;
		}
		now *= x;
	}
	if (co >= n) {
		return true;
	}
	else {
		return false;
	}
}
int main() {
	cin >> n;
	long long ans = 1000000000000007;
	for (long long i = 1; i <= 9; i++) {
		for (long long j = 1; j < 40; j++) {
			long long l = i, r = 2000000000000;
			while (r - l > 1) {
				long long mid = (l + r) / 2;
				if (solve(mid, i, j)) {
					r = mid;
				}
				else {
					l = mid;
				}
			}
			cout << i << " " << j << " " << r << endl;
			bool a = true;
			long long co = 0;
			long long now = 1;
			for (long long k = 0; k < j; k++) {
				co += now * i;
				if (100000000000000000 / now < r) {
					a = false;
					break;
				}
				now *= r;
			}
			if (co != n) {
				a = false;
			}
			if (a) {
				if (ans > r) {
					ans = r;
				}
			}
		}
	}
	cout << ans << endl;
}