結果
問題 |
No.3156 Count That Day's N
|
ユーザー |
![]() |
提出日時 | 2025-05-23 19:10:27 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 164 ms / 3,000 ms |
コード長 | 1,271 bytes |
コンパイル時間 | 5,943 ms |
コンパイル使用メモリ | 334,208 KB |
実行使用メモリ | 21,568 KB |
最終ジャッジ日時 | 2025-05-23 19:10:52 |
合計ジャッジ時間 | 9,867 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> #define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) using namespace atcoder; using namespace std; typedef long long ll; ll sqrt_ll(ll n) { // return floor(√n) auto check = [&](ll mid) { if (mid * mid <= n) return true; else return false; }; auto binary = [&]() { ll L = 0, R = 3000000010; // [L,R)の範囲内に解 ll mid = (L + R) / 2; while (R - L > 1) { if (check(mid)) L = mid; else R = mid; mid = (L + R) / 2; } return L; // L-true R-false }; ll ret = binary(); return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll k, n; cin >> k >> n; vector<ll> xy; rep(x, 1, 1000) rep(y, 1, 10000) { ll m = x * x * x * x * x * x + y * y * y * y; if (m > n) continue; xy.push_back(m); } sort(xy.begin(), xy.end()); xy.erase(unique(xy.begin(), xy.end()), xy.end()); ll ans = 0; for (auto v : xy) { if (v % k != 0) continue; ll z = sqrt_ll(v / k); ans += z * z * k == v; } cout << ans << endl; }