結果
| 問題 |
No.474 色塗り2
|
| コンテスト | |
| ユーザー |
rickytheta
|
| 提出日時 | 2016-12-24 01:54:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 88 ms / 2,000 ms |
| コード長 | 947 bytes |
| コンパイル時間 | 261 ms |
| コンパイル使用メモリ | 24,448 KB |
| 実行使用メモリ | 34,700 KB |
| 最終ジャッジ日時 | 2024-12-14 17:08:56 |
| 合計ジャッジ時間 | 853 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
36 | int t; scanf("%d",&t);
| ~~~~~^~~~~~~~~
main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d%d%d",&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
typedef long long ll;
const int YO = 2125212;
ll fact[YO];
ll bow[YO];
const int MO = 1<<21;
const int MASK = MO-1;
void extgcd(ll a,ll b,ll &x,ll &y){
x=1;
y=0;
if(b!=0){
extgcd(b,a%b,y,x);
y -= (a/b) * x;
}
}
ll modinv(ll v){
ll x,y;
extgcd(v,MO,x,y);
return (x+MO)&MASK;
}
int main(){
fact[0] = 1; bow[0] = 0;
for(int i=1;i<YO;i++){
int v = i;
bow[i] = bow[i-1];
while(v%2==0){
bow[i]++; v/=2;
}
fact[i] = (fact[i-1]*v) & MASK;
}
int t; scanf("%d",&t);
while(t--){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(c%2==0){
puts("0");
}else{
ll x = (((((fact[c+b-1] *modinv(fact[b]))&MASK) *modinv(fact[c-1]))&MASK) *c)&MASK;
ll bin = bow[c+b-1] - bow[b] - bow[c-1];
while(x!=0 && bin--){
x = (x<<1)&MASK;
}
x = (x+a-1+MO)&MASK;
int check = (~x)&a;
puts(check!=0 ? "0" : "1");
}
}
return 0;
}
rickytheta