結果
問題 | No.864 四方演算 |
ユーザー |
|
提出日時 | 2021-05-30 21:41:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 1,000 ms |
コード長 | 553 bytes |
コンパイル時間 | 1,940 ms |
コンパイル使用メモリ | 191,620 KB |
最終ジャッジ日時 | 2025-01-21 20:48:31 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#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>; int main() { ll n, k; cin >> n >> k; auto f = [&](ll x) { if (x <= n + 1) return x - 1; else if (x >= 2 * n + 1) return 0LL; else return 2 * n - x + 1; }; ll ans = 0; for (ll i = 2; i * i <= k; i++) { if (k % i != 0) continue; ll x = f(i), y = f(k / i); if (i * i != k) ans += x * y * 2; else ans += x * y; } cout << ans << endl; }