結果

問題 No.1383 Numbers of Product
ユーザー 蜜蜂蜜蜂
提出日時 2020-12-15 18:10:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,079 bytes
コンパイル時間 1,744 ms
コンパイル使用メモリ 175,064 KB
実行使用メモリ 25,280 KB
最終ジャッジ日時 2023-09-17 16:07:45
合計ジャッジ時間 6,156 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 61 ms
21,688 KB
testcase_08 AC 64 ms
22,244 KB
testcase_09 AC 70 ms
24,624 KB
testcase_10 AC 93 ms
24,312 KB
testcase_11 AC 93 ms
23,668 KB
testcase_12 AC 94 ms
23,752 KB
testcase_13 AC 97 ms
24,260 KB
testcase_14 AC 80 ms
23,080 KB
testcase_15 AC 62 ms
21,808 KB
testcase_16 AC 91 ms
24,656 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 WA -
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 77 ms
23,288 KB
testcase_30 AC 99 ms
23,888 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 17 ms
7,888 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 82 ms
23,928 KB
testcase_36 AC 89 ms
24,068 KB
testcase_37 AC 131 ms
24,452 KB
testcase_38 AC 124 ms
24,068 KB
testcase_39 AC 116 ms
24,720 KB
testcase_40 AC 116 ms
23,960 KB
testcase_41 AC 128 ms
24,616 KB
testcase_42 AC 121 ms
25,280 KB
testcase_43 AC 118 ms
24,144 KB
testcase_44 AC 103 ms
24,856 KB
testcase_45 AC 104 ms
23,772 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 84 ms
23,880 KB
testcase_48 AC 85 ms
23,356 KB
testcase_49 AC 94 ms
24,748 KB
testcase_50 AC 97 ms
24,220 KB
testcase_51 WA -
testcase_52 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;
#define fi first
#define se second

bool b1(ll n,ll k){
  long double z=(-k+sqrt(k*k+4*n))/2;
  ll check=z+0.5;
  return check*(check+k)==n;
}

int main(){
  ll n,k,m;
  cin>>n>>k>>m;
  if(m>23){
    cout<<0<<endl;
    return 0;
  }
  vector<ll> more2;
  ll start,flag;
  for(ll i=2;i<=20;i++){
    start=1;
    flag=0;
    while(flag==0){
      ll x=start;
      for(ll j=1;j<=i;j++){
        if(n/x<start+j*k){
          flag++;
          break;
        }
        x*=(start+j*k);
      }
      start++;
      if(x<=n&&flag==0){
        more2.push_back(x);
      }
    }
  }
  
  if(more2.size()==0){
    if(m>1){
      cout<<0<<endl;
      return 0;
    }
    else{
      ll ok=-1,ng=1e12;
      while(ng-ok>1){
        ll check=(ok+ng)/2;
        if(check<=n/(check+k)){
          ok=check;
        }
        else{
          ng=check;
        }
      }
      cout<<n-ok<<endl;
      return 0;
    }
  }
  sort(more2.begin(),more2.end());
  vector<vector<ll>> s(25);
  int now=0;
  while(now<more2.size()){
    ll x=more2[now];
    int z=0;
    while(more2[now]==x&&now<more2.size()){
      z++;
      now++;
    }
    s[z].push_back(x);
  }
  
  if(m==1){
    ll ok=-1,ng=1e9;
    while(ng-ok>1){
      ll check=(ok+ng)/2;
      if(check<=n/(check+k)){
        ok=check;
      }
      else{
        ng=check;
      }
    }
    ll ans=s[1].size()+ok;
    if(s[1].size()>0){
      for(ll x:s[1]){
        if(b1(x,k)==true){
          ans--;
        }
      }
    }
    ll w=0;
    for(int i=0;i<25;i++){
      if(s[i].size()>0){
        for(ll x:s[i]){
          if(b1(x,k)==true){
            w++;
          }
        }
      }
    }
    cout<<ans-w<<endl;
    return 0;
  }
  else{
    ll ans=0;
    if(s[m].size()>0){
      for(ll x:s[m]){
        if(b1(x,k)==false){
          //cout<<x<<endl;
          ans++;
        }
      }
    }
    if(s[m-1].size()>0){
      for(ll x:s[m-1]){
        if(b1(x,k)==true){
          //cout<<x<<endl;
          ans++;
        }
      }
    }
    cout<<ans<<endl;
  }
}
0