結果

問題 No.153 石の山
ユーザー outlineoutline
提出日時 2021-02-20 19:25:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,031 bytes
コンパイル時間 1,324 ms
コンパイル使用メモリ 135,132 KB
最終ジャッジ日時 2025-01-19 02:46:15
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;
template<class T>
inline bool chmax(T& x, T y){
if(x < y){
x = y;
return true;
}
return false;
}
template<class T>
inline bool chmin(T& x, T y){
if(x > y){
x = y;
return true;
}
return false;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> dp(n + 1, -1);
auto func = [&](auto&& self, int x) -> int {
if(dp[x] != -1) return dp[x];
if(x == 1) return dp[x] = 0;
set<int> G;
if(x % 2 == 0){
G.emplace(self(self, x / 2) ^ self(self, x / 2));
}
else{
G.emplace(self(self, x / 2) ^ self(self, x / 2 + 1));
}
if(x >= 3){
if(x % 3 == 0){
G.emplace(self(self, x / 3) ^ self(self, x / 3) ^ self(self, x / 3));
}
else if(x % 3 == 1){
G.emplace(self(self, x / 3) ^ self(self, x / 3) ^ self(self, x / 3 + 1));
}
else{
G.emplace(self(self, x / 3) ^ self(self, x / 3 + 1) ^ self(self, x / 3 + 1));
}
}
int res = 0;
for(int i = 0; i <= 5; ++i){
if(!G.count(i)){
res = i;
break;
}
}
return dp[x] = res;
};
cout << (func(func, n) ? "A\n" : "B\n");
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0