結果
| 問題 |
No.864 四方演算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-16 21:55:17 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 1,000 ms |
| コード長 | 1,118 bytes |
| コンパイル時間 | 753 ms |
| コンパイル使用メモリ | 128,848 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 14:31:27 |
| 合計ジャッジ時間 | 1,945 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <cstring>
#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define eREP(i, n) for(int (i) = 0; (i) <= (n); ++(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()
template <class T> inline T& chmax(T& a, T b){return (a < b) ? a = b : a;}
template <class T> inline T& chmin(T& a, T b){return (a > b) ? a = b : a;}
using lli = long long int;
int main(void){
lli n, k; std::cin >> n >> k;
// (a + c)(b + d) = K
lli res = 0;
for(lli x = 2; x * x <= k; x++) if(k % x == 0){
lli y = k / x;
if(not(2 <= x and x <= 2 * n and 2 <= y and y <= 2 * n)) continue;
// a + c = x
// b + d = y
// c = x - a -> 1 ≤ x - a ≤ N => x - N ≤ a ≤ x - 1
lli L = x - n; if(L < 1) L = 1;
lli U = x - 1; if(U > n) U = n;
lli A = U - L + 1;
L = y - n; if(L < 1) L = 1;
U = y - 1; if(U > n) U = n;
lli B = U - L + 1;
if(x == y) res += A * B;
else res += 2 * A * B;
}
std::cout << res << '\n';
return 0;
}