結果
問題 |
No.153 石の山
|
ユーザー |
|
提出日時 | 2020-04-06 23:27:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,521 bytes |
コンパイル時間 | 1,624 ms |
コンパイル使用メモリ | 167,180 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 04:52:58 |
合計ジャッジ時間 | 2,528 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; //#include <boost/multiprecision/cpp_ll.hpp> //typedef boost::multiprecision::cpp_ll ll; typedef long double dd; #define i_7 (ll)(1E9+7) //#define i_7 998244353 #define i_5 i_7-2 ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; return c+i_7; } typedef pair<ll,ll> l_l; ll inf=(ll)1E16; #define rep(i,l,r) for(ll i=l;i<=r;i++) #define pb push_back ll max(ll a,ll b){if(a<b)return b;else return a;} ll min(ll a,ll b){if(a>b)return b;else return a;} void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]); void Min(ll &pos,ll val){pos=min(pos,val);} void Add(ll &pos,ll val){pos=mod(pos+val);} dd EPS=1E-9; #define endl "\n" #define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll g[1000]; ll hoge(ll x){ if(x==1)return 0; bool b[1000];rep(i,0,999)b[i]=false; if(x>=2){ if(x%2==0){ b[hoge(x/2)^hoge(x/2)]=1; }else{ b[hoge((x+1)/2)^hoge((x-1)/2)]=1; } } if(x>=3){ if(x%3==0){ b[hoge(x/3)^hoge(x/3)^hoge(x/3)]=1; }else if(x%3==1){ b[hoge((x-1)/3)^hoge((x-1)/3)^hoge((x-1)/3+1)]=1; }else{ b[hoge((x-2)/3)^hoge((x-2)/3+1)^hoge((x-2)/3+1)]=1; } } rep(i,0,999){ if(!b[i]){ return g[x]=i; } } return 1; } int main(){fastio ll n;cin>>n; if(hoge(n)==0){ cout<<"B"<<endl; }else{ cout<<"A"<<endl; } return 0; }