結果

問題 No.864 四方演算
ユーザー 37zigen37zigen
提出日時 2019-08-16 23:37:24
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 557 bytes
コンパイル時間 404 ms
使用メモリ 3,552 KB
最終ジャッジ日時 2022-11-24 11:32:39
合計ジャッジ時間 2,085 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,376 KB
testcase_01 AC 12 ms
3,528 KB
testcase_02 AC 9 ms
3,472 KB
testcase_03 AC 10 ms
3,440 KB
testcase_04 AC 11 ms
3,444 KB
testcase_05 AC 8 ms
3,516 KB
testcase_06 AC 11 ms
3,552 KB
testcase_07 AC 10 ms
3,520 KB
testcase_08 AC 10 ms
3,476 KB
testcase_09 AC 6 ms
3,476 KB
testcase_10 AC 5 ms
3,420 KB
testcase_11 AC 4 ms
3,476 KB
testcase_12 AC 9 ms
3,424 KB
testcase_13 AC 7 ms
3,516 KB
testcase_14 AC 3 ms
3,440 KB
testcase_15 AC 13 ms
3,500 KB
testcase_16 AC 10 ms
3,372 KB
testcase_17 AC 11 ms
3,476 KB
testcase_18 AC 10 ms
3,436 KB
testcase_19 AC 8 ms
3,496 KB
testcase_20 AC 11 ms
3,368 KB
testcase_21 AC 9 ms
3,524 KB
testcase_22 AC 9 ms
3,436 KB
testcase_23 AC 2 ms
3,444 KB
testcase_24 AC 8 ms
3,528 KB
testcase_25 AC 5 ms
3,496 KB
testcase_26 AC 8 ms
3,376 KB
testcase_27 AC 1 ms
3,372 KB
testcase_28 AC 2 ms
3,516 KB
testcase_29 AC 2 ms
3,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

long long f(long long sum, long long lim) {
  if (lim + lim < sum) return 0;
  long long ma = std::min(sum - 1, lim);
  long long mi = sum - ma;
  return ma - mi + 1;
}

// ab + bc + cd + da   = K
// a(b + d) + c(b + d) = K
// (a + c)(b + d)      = K

int main() {
  long long N, K;
  std::cin >> N >> K;
  long long ans = 0;
  for (long long div = 2; div * div <= K; ++div) {
    if(K % div != 0) continue;
    long long div2 = K / div;
    ans += f(div, N) * f(div2, N) * (div == div2 ? 1 : 2);
  }
  std::cout << ans << std::endl;
}
0