結果
問題 | No.864 四方演算 |
ユーザー |
![]() |
提出日時 | 2019-08-20 21:15:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 1,000 ms |
コード長 | 632 bytes |
コンパイル時間 | 638 ms |
コンパイル使用メモリ | 73,772 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-06 16:07:24 |
合計ジャッジ時間 | 1,705 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { long long n, k; cin >> n >> k; vector<pair<long long, long long>> candy; // a + c, b + d for (long long i = 1; i * i <= k; i++) { if (k % i) continue; candy.emplace_back(i, k / i); if (i * i != k) candy.emplace_back(k / i, i); } auto calc = [&](long long x) { if (x <= 1 || x > n * 2) return 0LL; return n - abs(n + 1 - x); }; long long ans = 0; for (auto &p: candy) { ans += calc(p.first) * calc(p.second); } cout << ans << endl; return 0; }