結果
問題 | No.1352 Three Coins |
ユーザー | ぷら |
提出日時 | 2021-01-17 13:55:58 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 942 bytes |
コンパイル時間 | 1,580 ms |
コンパイル使用メモリ | 171,960 KB |
実行使用メモリ | 113,052 KB |
最終ジャッジ日時 | 2024-05-07 05:58:12 |
合計ジャッジ時間 | 7,207 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
13,752 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 283 ms
9,600 KB |
testcase_03 | AC | 46 ms
6,784 KB |
testcase_04 | AC | 5 ms
5,376 KB |
testcase_05 | AC | 1,819 ms
22,784 KB |
testcase_06 | TLE | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
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 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int> P; int INF = 3e18+7; int mod = 1e9+7; int dx[] = {1, 0,-1, 0, 1, 1,-1,-1}; int dy[] = {0, 1, 0,-1, 1,-1, 1,-1}; int gcd(int X,int Y) { if(X%Y == 0) { return Y; } else { return gcd(Y,X%Y); } } signed main() { int A,B,C; cin >> A >> B >> C; if(gcd(gcd(A,B),C) != 1) { cout << "INF" << endl; return 0; } int mn = INF; if(gcd(A,B) == 1) { mn = (A-1)*(B-1); } if(gcd(B,C) == 1) { mn = min(mn,(B-1)*(C-1)); } if(gcd(A,C) == 1) { mn = min(mn,(A-1)*(C-1)); } set<int>st; for(int i = 0; i <= 2000; i++) { for(int j = 0; j <= 2000 && A*i+B*j <= mn; j++) { for(int k = 0; k <= 2000 && A*i+B*j+C*k <= mn; k++) { st.insert(A*i+B*j+C*k); } } } cout << mn-st.size()+1 << endl; }