結果

問題 No.153 石の山
ユーザー chikkun0310chikkun0310
提出日時 2020-04-06 23:27:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,521 bytes
コンパイル時間 1,582 ms
コンパイル使用メモリ 165,668 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 10:51:39
合計ジャッジ時間 3,455 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}


0