結果
問題 | No.864 四方演算 |
ユーザー |
![]() |
提出日時 | 2019-08-27 07:02:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 12 ms / 1,000 ms |
コード長 | 679 bytes |
コンパイル時間 | 487 ms |
コンパイル使用メモリ | 58,584 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 04:17:44 |
合計ジャッジ時間 | 1,740 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <iostream> #include <math.h> using namespace std; typedef long long LL; inline LL count(LL sum, LL N) { LL ret = 0; if (1 < sum && sum <= N * 2) { ret = min(sum - 1, N) - max(1LL, sum - N) + 1; } // cout << "sum = " << sum << ", N = " << N << ", ret = " << ret << endl; return ret; } int main() { LL N, K; cin >> N >> K; LL ans = 0; //! ab+bc+cd+da = (a+c)(b+d) //! Suppose (a+c) <= (b+d) for (LL ac = 1; ac * ac <= K; ++ac) { if (K % ac == 0) { LL bd = K / ac; ans += count(ac, N) * count(bd, N) * (ac == bd ? 1 : 2); } } cout << ans << endl; return 0; }