結果

問題 No.1352 Three Coins
ユーザー DaYuanChi
提出日時 2021-01-17 21:27:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 594 bytes
コンパイル時間 2,285 ms
コンパイル使用メモリ 193,664 KB
最終ジャッジ日時 2025-01-18 01:58:16
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 TLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int cnt[4000005];

int main(){
  int a, b, c; cin >> a >> b >> c;
  if(gcd(a,gcd(b,c))>1){
    cout << "INF" << endl;
    return 0;
  }
  int n = 1;
  if(gcd(a,b)==1){
    n = a*b;
  }else if(gcd(b,c)==1){
    n = b*c;
  }else{
    n = c*a;
  }
  for(int i = 0; i <= n/a; i++){
    for(int j = 0; j <= (n-i*a)/b; j++){
      for(int k = 0; k <= (n-i*a-j*b)/c; k++){
        cnt[i*a+j*b+k*c]++;
      }
    }
  }
  int ans = 0;
  for(int i = 1; i < n; i++){
    if(cnt[i]==0) ans++;
  }
  cout << ans << endl;
  return 0;
}
  
0