結果

問題 No.395 永遠の17歳
ユーザー ant2357ant2357
提出日時 2016-07-15 23:03:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,454 bytes
コンパイル時間 1,594 ms
コンパイル使用メモリ 164,968 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 05:02:09
合計ジャッジ時間 2,454 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,944 KB
testcase_06 RE -
testcase_07 AC 2 ms
6,944 KB
testcase_08 WA -
testcase_09 RE -
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

//================================================
class Radix {
private:
	const char* s;
	int a[128];
public:
	Radix(const char* s = "0123456789ABCDEF") : s(s) {
		int i;
		for (i = 0; s[i]; ++i)
			a[(int)s[i]] = i;
	}
	std::string to(long long p, int q) {
		int i;
		if (!p)
			return "0";
		char t[64] = {};
		for (i = 62; p; --i) {
			t[i] = s[p % q];
			p /= q;
		}
		return std::string(t + i + 1);
	}
	std::string to(const std::string& t, int p, int q) {
		return to(to(t, p), q);
	}
	long long to(const std::string& t, int p) {
		int i;
		long long sm = a[(int)t[0]];
		for (i = 1; i < (int)t.length(); ++i)
			sm = sm * p + a[(int)t[i]];
		return sm;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	Radix r;
	int X, ans;
	cin >> X;

	for (int i = 2; true; i++) {

		if (i == 75) {
			ans = -1;
			break;
		}
		string tmp = r.to(X, i);
		int aidoru = stoi(tmp);
		if (aidoru == 17) {
			ans = i;
			break;
		}
	}
	
	cout << ans << "\n";
	return 0;
}
0