結果
| 問題 | No.864 四方演算 |
| コンテスト | |
| ユーザー |
i_mrhj
|
| 提出日時 | 2019-08-16 21:39:36 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 1,000 ms |
| コード長 | 868 bytes |
| 記録 | |
| コンパイル時間 | 337 ms |
| コンパイル使用メモリ | 31,104 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-25 10:44:01 |
| 合計ジャッジ時間 | 1,405 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
ll f(ll a, ll n) {
if (a <= n + 1) {
return a - 1;
} else if (n < a - n) {
return 0;
} else {
ll max, min;
max = Min(n, a - 1);
min = Max(1, a - n);
return max - min + 1;
}
}
int
main(int argc, char *argv[])
{
ll n, k;
scanf("%lld", &n);
scanf("%lld", &k);
ll a, b, ans = 0, x;
for (x = 2; x * x < k; x++) {
if (k % x == 0) {
a = x; b = k / x;
ans += f(a, n) * f(b, n);
}
}
ans = ans + ans;
if (x * x == k) ans += f(x, n) * f(x, n);
printf("%lld\n", ans);
return 0;
}
i_mrhj