結果
| 問題 |
No.864 四方演算
|
| ユーザー |
kyuna
|
| 提出日時 | 2019-08-20 21:14:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 620 bytes |
| コンパイル時間 | 650 ms |
| コンパイル使用メモリ | 73,992 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-06 16:07:18 |
| 合計ジャッジ時間 | 1,984 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 23 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long n, k; cin >> n >> k;
vector<pair<int, int>> 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;
}
kyuna