結果

問題 No.984 Inversion
ユーザー recososorecososo
提出日時 2020-02-11 15:14:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 1,502 ms
コンパイル使用メモリ 167,148 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-08 15:20:22
合計ジャッジ時間 2,343 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll p,n;cin >> p >> n;
    if(p==2){
        cout << 0 << endl;
        return 0;
    }
    bool f=true;
    if(n>p-n){
        f=false;
        n=p-n;
    }
    if(n==1){
        if(f){
            cout << 0 << endl;
        }
        else{
            if(((p-1)*p/2)%2==1){
                cout << 1 << endl;
            }
            else{
                cout << 0 << endl;
            }
        }
        return 0;
    }
    ll t=p/n;
    ll k=t*(t+1)/2;
    if(f){
        if(k%2==1){
            cout << 1 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
    else{
        if((k%2==1)^(((p-1)*p/2)%2==0)){
            cout << 1 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
}
0