結果

問題 No.1352 Three Coins
ユーザー DaYuanChiDaYuanChi
提出日時 2021-01-17 21:27:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 594 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 199,624 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2023-08-20 03:22:46
合計ジャッジ時間 11,478 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,768 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 8 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 37 ms
5,192 KB
testcase_06 AC 1,995 ms
13,708 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1,691 ms
13,540 KB
testcase_09 AC 436 ms
7,392 KB
testcase_10 AC 874 ms
9,444 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

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