結果
| 問題 |
No.2551 2, 3, 5, 7 Game
|
| コンテスト | |
| ユーザー |
Today03
|
| 提出日時 | 2023-11-25 18:50:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 997 bytes |
| コンパイル時間 | 1,992 ms |
| コンパイル使用メモリ | 202,240 KB |
| 最終ジャッジ日時 | 2025-02-18 01:08:45 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 TLE * 1 -- * 4 |
ソースコード
#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() {
int T;
cin >> T;
for (int i = 0; i < T; i++) {
solve();
}
}
Today03