結果
| 問題 |
No.3156 Count That Day's N
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-29 12:21:57 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 3,000 ms |
| コード長 | 985 bytes |
| コンパイル時間 | 7,137 ms |
| コンパイル使用メモリ | 199,280 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-05-29 12:22:07 |
| 合計ジャッジ時間 | 9,793 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
import std;
void main() {
long k, n;
readf("%d %d\n", k, n);
ulong[] a;
foreach(x; 1..kthRooti(n, 6) + 1) {
foreach(y; 1..kthRooti(n, 4) + 1) {
const kz = pow(x, 6UL) + pow(y, 4UL);
if(kz <= n && kz % k == 0 && isSquare(kz / k)) {
a ~= kz;
}
}
}
writeln(a.sort.uniq.walkLength);
}
pragma(inline)
ulong kthRooti(const ulong n, const int k) {
if(k == 1) {
return n;
}
const chk = (const ulong x) {
ulong mul = 1;
bool of;
for(int i = 0; i < k; ++i) {
mul = opChecked!"*"(mul, x, of);
if(of) {
return false;
}
}
return mul <= n;
};
ulong ret = 0;
for(int i = 32; --i >= 0;) {
if(chk(ret | (1UL << i))) {
ret |= 1UL << i;
}
}
return ret;
}
pragma(inline)
bool isInt(const double n){ return n == floor(n); }
pragma(inline)
bool isSquare(const ulong n){ return isInt(sqrt(cast(double)n)); }