結果
問題 |
No.2519 Coins in Array
|
ユーザー |
![]() |
提出日時 | 2023-08-29 20:25:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 603 bytes |
コンパイル時間 | 1,994 ms |
コンパイル使用メモリ | 199,272 KB |
最終ジャッジ日時 | 2025-02-16 15:36:30 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 4 |
other | WA * 37 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; ll f(ll x, ll y) { return (gcd(x, y) == 1) ? (x - 1) * (y - 1) : 0; } int main(){ int n; cin >> n; vector<ll> a(n); for(auto& x : a){ cin >> x; } sort(a.begin(), a.end()); if(n >= 4){ cout << 0 << endl; return 0; } ll ans = 1ll << 62; do{ ll t = (n == 2) ? f(a[0], a[1]) : f(f(a[0], a[1]), a[2]); if(ans <= t){ continue; } ans = t; }while(next_permutation(a.begin(), a.end())); cout << ans << endl; return 0; }