結果

問題 No.1383 Numbers of Product
ユーザー umezoumezo
提出日時 2021-02-07 22:52:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 974 bytes
コンパイル時間 3,254 ms
コンパイル使用メモリ 205,412 KB
実行使用メモリ 131,132 KB
最終ジャッジ日時 2023-09-17 23:57:31
合計ジャッジ時間 42,497 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
4,376 KB
testcase_01 AC 41 ms
4,380 KB
testcase_02 AC 41 ms
4,380 KB
testcase_03 AC 52 ms
4,376 KB
testcase_04 AC 52 ms
4,380 KB
testcase_05 AC 52 ms
4,376 KB
testcase_06 AC 51 ms
4,380 KB
testcase_07 AC 1,040 ms
105,664 KB
testcase_08 WA -
testcase_09 AC 773 ms
114,512 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 51 ms
4,504 KB
testcase_18 AC 52 ms
4,376 KB
testcase_19 AC 50 ms
4,376 KB
testcase_20 WA -
testcase_21 AC 51 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 51 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 52 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 596 ms
66,800 KB
testcase_29 AC 1,156 ms
115,776 KB
testcase_30 AC 1,356 ms
130,716 KB
testcase_31 AC 481 ms
65,932 KB
testcase_32 AC 609 ms
79,220 KB
testcase_33 WA -
testcase_34 AC 500 ms
65,924 KB
testcase_35 AC 856 ms
125,028 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 900 ms
130,716 KB
testcase_40 AC 907 ms
130,764 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 915 ms
130,824 KB
testcase_45 WA -
testcase_46 AC 53 ms
4,380 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

const double EPS=1e-9;

ll n,k,m;
bool f(ll x){
  if(n<1e6) return false;
  double l=1e6;
  double r=n;
  rep(i,50){
    double a=(l+r)/2;
    if(a*a+k*a-x>EPS) r=a;
    else if(a*a+k*a-x<-EPS) l=a;
  }
  if(abs(r-round(r))<EPS) return true;
  else return false;
}

int main(){
  cin>>n>>k>>m;
  
  map<ll,ll> M;
  for(ll a=1;a<1000000;a++){
    ll tmp=a;
    for(ll b=1;;b++){
      if(log(tmp)+log(a+b*k)>log(n)) break;
      tmp*=a+b*k;
      M[tmp]++;
    }
  }
  
  ll ans=0;
  if(m>=2){
    for(auto x:M){
      if(x.second==m && f(x.first)==false) ans++;
      if(x.second==m-1 && f(x.first)==true) ans++;
    }
  }
  if(m==1){
    ans+=max(0LL,n-1000000LL);
    for(auto x:M){
      if(f(x.first)==true) ans--;
      if(x.second==m && f(x.first)==false) ans++;
    } 
  }
  cout<<ans<<endl;
    
  return 0;
}
0