結果

問題 No.864 四方演算
ユーザー 0w1
提出日時 2019-08-28 02:56:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 490 bytes
コンパイル時間 2,116 ms
コンパイル使用メモリ 191,996 KB
最終ジャッジ日時 2025-01-07 15:25:39
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int64_t N, K;
  cin >> N >> K;

  int64_t ans = 0;
  for (int i = 1; 1LL * i * i <= K; ++i) {
    int64_t j = K / i;
    if (1LL * i * j != K) continue;
    auto calc = [&](int64_t q) -> int64_t {
      if (q <= N) return q - 1;
      if (q < 2 * N + 1) return N - (q - N) + 1;
      return 0;
    };
    ans += 1LL * calc(i) * calc(j);
    if (i != j) ans += 1LL * calc(i) * calc(j);
  }

  cout << ans << endl;

  return 0;
}
0