結果

問題 No.3156 Count That Day's N
ユーザー askr58
提出日時 2025-05-23 19:08:21
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 81 ms / 3,000 ms
コード長 617 bytes
コンパイル時間 4,854 ms
コンパイル使用メモリ 334,876 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-23 19:08:28
合計ジャッジ時間 6,685 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;

int main()
{
    ll k,n;
    cin>>k>>n;
    auto is_sq=[](ll x)->bool{
        ll l=0,r=1000000000;
        while(l+1<r){
            ll c=(l+r)/2;
            if(c*c<=x)l=c;
            else r=c;
        }
        return l*l==x;
    };
    set<ll> s;
    for(ll x=1;x<=1000;x++){
        for(ll y=1;y<=10000;y++){
            ll t=x*x*x*x*x*x+y*y*y*y;
            if(t>n||t%k!=0)continue;
            t/=k;
            if(is_sq(t))s.insert(t);
        }
    }
    cout<<s.size()<<endl;
    return 0;
}
0