結果
問題 | No.864 四方演算 |
ユーザー |
![]() |
提出日時 | 2019-09-15 12:19:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 1,000 ms |
コード長 | 830 bytes |
コンパイル時間 | 1,255 ms |
コンパイル使用メモリ | 166,608 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 22:41:44 |
合計ジャッジ時間 | 2,398 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include<bits/stdc++.h> #define rep(i,n,m) for(int i = (n); i <(m); i++) #define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--) using namespace std; using ll = long long; int main() { ll n, k; cin >> n >> k; ll ans = 0; for (ll num = 1; num*num <= k; num++) if (k % num == 0) { ll num2 = k / num; ll cnt1 = (num - 1); ll cnt2 = (num2 - 1); if (num - 1 > n) cnt1 -= 2 * (num - 1 - n); if (num2 - 1 > n) cnt2 -= 2 * (num2 - 1 - n); cnt1 = max(0LL, cnt1); cnt2 = max(0LL, cnt2); if (num == num2) ans += cnt1 * cnt2; else ans += 2 * cnt1 * cnt2; // cout << num << ' ' << num2 << ' ' << cnt1 << ' ' << cnt2 << ' ' << endl; } cout << ans << endl; return 0; }