結果

問題 No.3156 Count That Day's N
ユーザー テナガザル
提出日時 2025-05-23 19:43:48
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 491 ms / 3,000 ms
コード長 568 bytes
コンパイル時間 4,944 ms
コンパイル使用メモリ 106,096 KB
実行使用メモリ 29,952 KB
最終ジャッジ日時 2025-05-23 19:43:58
合計ジャッジ時間 5,966 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
  long long k, n;
  cin >> k >> n;
  set<long long> st;
  for (long long x = 1; true; ++x)
  {
    long long x6 = x * x * x * x * x * x;
    if (x6 >= n) break;
    for (long long y = 1; true; ++y)
    {
      long long tmp = y * y * y * y + x6;
      if (tmp > n) break;
      if (tmp % k) continue;
      st.insert(tmp / k);
    }
  }
  int ans = 0;
  for (long long z = 1; z * z * k <= n; ++z) ans += (st.find(z * z) != st.end());
  cout << ans << endl;
}
0