結果
問題 | No.864 四方演算 |
ユーザー |
|
提出日時 | 2020-04-27 11:27:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 1,000 ms |
コード長 | 715 bytes |
コンパイル時間 | 1,004 ms |
コンパイル使用メモリ | 84,764 KB |
最終ジャッジ日時 | 2025-01-10 02:27:38 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <iostream>#include <cmath>#include <vector>template <class T>std::vector<T> divisors(T n) {std::vector<T> ret;for (T p = 1; p * p <= n; ++p) {if (n % p != 0) continue;ret.push_back(p);if (n / p == p) continue;ret.push_back(n / p);}return ret;}using lint = long long;void solve() {lint n, k;std::cin >> n >> k;lint ans = 0;for (auto d : divisors(k)) {ans += std::max(n - std::abs(n + 1 - d), 0LL) *std::max(n - std::abs(n + 1 - k / d), 0LL);}std::cout << ans << std::endl;}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);solve();return 0;}