結果

問題 No.474 色塗り2
ユーザー snukesnuke
提出日時 2016-12-18 01:10:28
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,470 bytes
コンパイル時間 1,218 ms
コンパイル使用メモリ 145,564 KB
実行使用メモリ 159,840 KB
最終ジャッジ日時 2023-08-21 05:29:07
合計ジャッジ時間 11,976 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 89 ms
159,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define fi first
#define se second
using namespace std;
typedef long long int ll;

const int MX = 10000005;
// mod
const int K = 24;
const int mod = 1<<K;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
};
mint ex(mint a, ll t) {
  if(!t) return 1;
  mint res = ex(a,t/2);
  res *= res;
  return (t&1)?res*a:res;
}
//

typedef pair<mint,int> P;
P p[MX];

mint inv(mint a) { return ex(a,mod/2-1);}
mint comb(int a, int b) {
  int c = a-b;
  int two = p[a].se-p[b].se-p[c].se;
  if (two >= K) return 0;
  mint res = p[a].fi*inv(p[b].fi)*inv(p[c].fi);
  res *= 1<<two;
  return res;
}

int main() {
  int ts;
  scanf("%d",&ts);
  p[0] = P(1,0);
  rep(i,MX) if (i) {
    p[i] = p[i-1];
    int x = i;
    while (x%2 == 0) p[i].se++, x >>= 1;
    p[i].fi *= x;
  }
  rep(ti,ts) {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    // C(C(c+b-1,b)*c+a-1,a)*c
    mint x = comb(c+b-1,b)*c;
    mint y = comb((x+a-1).x,a)*c;
    printf("%lld\n", y.x&1);
  }
  return 0;
}
0