結果

問題 No.2551 2, 3, 5, 7 Game
ユーザー Today03Today03
提出日時 2023-11-25 19:03:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,046 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 212,144 KB
実行使用メモリ 13,352 KB
最終ジャッジ日時 2023-11-25 19:03:54
合計ジャッジ時間 12,919 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,062 ms
12,436 KB
testcase_01 AC 1,200 ms
6,548 KB
testcase_02 AC 1,082 ms
6,548 KB
testcase_03 AC 1,033 ms
6,548 KB
testcase_04 AC 1,101 ms
6,548 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include("Today's/debug.cpp")
#include "Today's/debug.cpp"
#else
#define debug(...)
#define print_line
#define debugc(...)
#define cerr \
	if (false) cerr
#endif

void solve() {
	long long N;
	cin >> N;
	//true:sepa,false:ryota
	map<pair<long long, int>, bool> mp;
	vector<int> num = {2, 3, 5, 7};
	auto F = [&](auto&& F, long long now, int turn) -> bool {
		if (mp.count(make_pair(now, turn))) {
			return mp[make_pair(now, turn)];
		}
		if (turn == 0) {
			if (now >= N) {
				return true;
			}
			bool res = false;
			for (int x : num) {
				res |= F(F, now * x, 1 - turn);
			}
			return mp[make_pair(now, turn)] = res;
		} else {
			if (now >= N) {
				return false;
			}
			bool res = false;
			for (int x : num) {
				res |= !F(F, now * x, 1 - turn);
			}
			return mp[make_pair(now, turn)] = !res;
		}
	};
	cout << (F(F, 1, 0) ? "sepa\n" : "ryota\n");
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	for (int i = 0; i < T; i++) {
		solve();
	}
}
0