結果

問題 No.3156 Count That Day's N
ユーザー Salt
提出日時 2025-05-23 20:36:27
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,927 ms / 3,000 ms
コード長 1,180 bytes
コンパイル時間 3,288 ms
コンパイル使用メモリ 283,392 KB
実行使用メモリ 86,912 KB
最終ジャッジ日時 2025-05-23 20:37:05
合計ジャッジ時間 36,225 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//https://boostjp.github.io/tips/multiprec-int.html

#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define YN {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}// if(a==b)YN;
#define NO2 cout<<-1<<endl

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i=int(n)-1; i>=0; --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main() {
    ll K, N;
    cin >> K >> N;

    vector<ll> X, Y;
    ll n = 1;
    ll x = 1;
    while (x <= N) {
        X.emplace_back(x);
        n++;
        x = n*n*n*n*n*n;
    }
    n = 1;
    ll y = 1;
    while (y <= N) {
        Y.emplace_back(y);
        n++;
        y = n*n*n*n;
    }

    //cerr << X.size() << ' ' << Y.size() << endl;

    set<ll> st;
    for (ll x:X) {
        for (ll y:Y) {
            st.insert(x+y);
        }
    }
    ll num = K;
    ll d = 1;
    ll ans = 0;
    while (num <= N) {
        //cerr << d << endl;
        if (st.find(num) != st.end()) ans++;
        d++;
        num = K*d*d;
    }

    cout << ans << endl;
    return 0;
}
0