結果
| 問題 |
No.474 色塗り2
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2019-08-06 00:06:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 151 ms / 2,000 ms |
| コード長 | 1,579 bytes |
| コンパイル時間 | 690 ms |
| コンパイル使用メモリ | 99,308 KB |
| 実行使用メモリ | 42,496 KB |
| 最終ジャッジ日時 | 2024-07-18 13:50:28 |
| 合計ジャッジ時間 | 1,817 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:67:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
67 | scanf("%d", &t);
| ~~~~~^~~~~~~~~~
main.cpp:71:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
71 | scanf("%d %d %d", &a, &b, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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;
}
chocorusk