結果
問題 | No.917 Make One With GCD |
ユーザー | Mister |
提出日時 | 2020-04-26 13:20:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 934 bytes |
コンパイル時間 | 877 ms |
コンパイル使用メモリ | 88,312 KB |
実行使用メモリ | 16,824 KB |
最終ジャッジ日時 | 2024-04-28 11:56:13 |
合計ジャッジ時間 | 7,464 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
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 <iostream> #include <numeric> #include <vector> #include <map> using lint = long long; std::map<int, lint> count(int n) { std::vector<int> xs(n); for (auto& x : xs) std::cin >> x; std::map<int, lint> ret; for (int b = 0; b < (1 << n); ++b) { lint g = 0; for (int i = 0; i < n; ++i) { if ((b >> i) & 1) g = std::gcd(g, xs[i]); } if (!ret.count(g)) ret[g] = 0; ++ret[g]; } return ret; } void solve() { int n; std::cin >> n; auto fore = count(n / 2), back = count(n - n / 2); lint ans = 0; for (auto p : fore) { for (auto q : back) { if (std::gcd(p.first, q.first) == 1) { ans += p.second * q.second; } } } std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }