結果

問題 No.847 Divisors of Power
ユーザー ttttan2ttttan2
提出日時 2019-07-05 22:27:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,076 bytes
コンパイル時間 1,789 ms
コンパイル使用メモリ 181,616 KB
実行使用メモリ 817,840 KB
最終ジャッジ日時 2024-04-16 07:43:48
合計ジャッジ時間 5,586 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 44 ms
10,752 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 114 ms
11,648 KB
testcase_05 AC 112 ms
12,416 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 113 ms
16,128 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 9 ms
5,376 KB
testcase_15 MLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll n,k,m;
vector<ll> pri;
bool prijud(ll n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k>>m;
    bool used[100010];
    fill(used,used+100010,false);
    rep(i,2,100010){
        if(used[i])continue;
        pri.push_back(i);
        for(int j=i;j<100010;j+=i)used[j]=true;
    }
    vector<pll> v;
    rep(i,0,pri.size()){
        if(pri[i]*pri[i]>n)break;
        if(n%pri[i]!=0)continue;
        ll cnt=0;
        ll u=n;
        while(u%pri[i]==0){
            cnt++;
            u/=pri[i];
        }
        if(cnt>0){
            v.push_back(make_pair(pri[i],cnt));
        }
        if(prijud(n/pri[i])){
            u=n;
            ll y=n/pri[i];
            if(n%y==0)v.push_back(make_pair(y,1));
            
        }
    }
    sort(v.begin(),v.end());
    rep(i,0,v.size()){
        v[i].second*=k;
    }
    queue<pair<vector<pll>,ll> >q;
    q.push(make_pair(v,1));
    set<ll> ans;
    while(q.size()>0){
        pair<vector<pll>,ll> p=q.front();q.pop();
        vector<pll> w=p.first;ll now=p.second;
        ans.insert(now);
        rep(i,0,w.size()){
            ll r=w[i].first;
            ll t=w[i].second;
            if(t==0)continue;
            vector<pll> ww=w;
            if(now*r<=m){
                ww[i]=make_pair(r,t-1);
                q.push(make_pair(ww,now*r));
            }
            
        }
    }
    ll anss=ans.size();
    cout<<anss<<endl;
}
0