結果

問題 No.1352 Three Coins
ユーザー 👑 Nachia
提出日時 2021-01-17 13:27:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 194,788 KB
最終ジャッジ日時 2025-01-18 00:27:34
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const ULL bitsetsize = 4000001;
bitset<bitsetsize> sieve;
bitset<bitsetsize> buf;

ULL GCD(ULL a,ULL b){ return b?GCD(b,a%b):a; }

int main(){
  ULL A,B,C; cin>>A>>B>>C;
  if(GCD(GCD(A,B),C)!=1){ cout<<"INF"<<endl; return 0; }
  sieve.set(0);
  rep(i,30){ buf=sieve; buf<<=A<<i; sieve|=buf; }
  rep(i,30){ buf=sieve; buf<<=B<<i; sieve|=buf; }
  rep(i,30){ buf=sieve; buf<<=C<<i; sieve|=buf; }
  cout<<(bitsetsize-sieve.count())<<endl;
  return 0;
}
0