結果

問題 No.474 色塗り2
ユーザー chocoruskchocorusk
提出日時 2019-08-06 00:06:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 1,579 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 96,640 KB
実行使用メモリ 42,616 KB
最終ジャッジ日時 2023-09-25 17:36:13
合計ジャッジ時間 1,913 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
42,440 KB
testcase_01 AC 100 ms
42,616 KB
testcase_02 AC 99 ms
42,500 KB
testcase_03 AC 141 ms
42,592 KB
testcase_04 AC 100 ms
42,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1<<20;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD/2-1);
}
ll f[2000001], invf[2000001];
int fe[2000001];
void fac(int n){
    f[0]=invf[0]=1;
    for(ll i=1; i<=n; i++){
        int e=0;
        ll x=i;
        while(x%2==0){
            x/=2;
            e++;
        }
        f[i]=f[i-1]*x%MOD;
        fe[i]=fe[i-1]+e;
        invf[i]=inv(f[i]);
    }
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    int e=fe[x]-fe[y]-fe[x-y];
    if(e>=20) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD*(1ll<<e)%MOD;
}
int main()
{
    int t;
    scanf("%d", &t);
    fac(2000000);
    for(int i=0; i<t; i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        if(c%2==0){
            printf("0\n");
            continue;
        }
        ll x=(comb(c+b-1, b)*c+a-1)%MOD;
        if((x&a)==a) printf("1\n");
        else printf("0\n");
    }
    return 0;
}
0