結果

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

ソースコード

diff #

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

bool is_sq(ll N){
	ll n = sqrtl(N);
	while(n * n > N) n--;
	while(n * n < N) n++;
	return n * n == N;
}

int main(){
    ll N, K;
    cin >> K >> N;
    vector<ll> ans;
    for(ll x = 1; x < 320; x++){
    	for(ll y = 1; y < 10000; y++){
    		ll w = x * x * x * x * x * x + y * y * y * y;
    		if(w > N) break;
    		if(w % K == 0 && is_sq(w / K)) ans.emplace_back(w / K);
    	}
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    cout << ans.size() << endl;
    return 0;
}
0