結果
問題 | No.1352 Three Coins |
ユーザー | platinum |
提出日時 | 2021-01-17 15:01:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 570 bytes |
コンパイル時間 | 2,136 ms |
コンパイル使用メモリ | 197,376 KB |
最終ジャッジ日時 | 2025-01-18 01:02:51 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (int)(n); i++) using namespace std; using LL = long long; using P = pair<int,int>; const int INF = 2e9; int main(){ vector<int> A(3); rep(i,3) cin >> A[i]; sort(A.begin(), A.end()); if(gcd(gcd(A[0], A[1]), A[2]) != 1){ cout << "INF" << endl; return 0; } vector<int> res(A[0], INF); rep(y,A[0]){ rep(z,A[0]){ int sum = y * A[1] + z * A[2]; int num = sum % A[0]; res[num] = min(res[num], sum / A[0]); } } int ans = 0; rep(i,A[0]) ans += res[i]; cout << ans << endl; return 0; }