求助
  • 板块题目总版
  • 楼主FinderHT
  • 当前回复6
  • 已保存回复6
  • 发布时间2023/5/2 09:20
  • 上次更新2023/10/23 16:57:36
查看原帖
求助
921348
FinderHT楼主2023/5/2 09:20

zhx的课,代码95分求调

#include<bits/stdc++.h>
#define gt getchar
#define pt putchar
typedef unsigned long long ll;
using namespace std;
inline bool pts(char ch){return ch>=48&&ch<=57;}
inline ll read(){
	bool f=0;ll x=0;char ch;
	ch=gt();
	while(!pts(ch)&&ch!=EOF){if(ch=='-')f=1;ch=gt();}
	while(pts(ch)){x*=10;x+=(ch-48);ch=gt();}
	if(f)return -x;
	else return x;
}
inline void print(ll x){
	char s[114];
	int top=0;
	if(x<0)pt('-');
	do{
		top++;
		if(x>=0)s[top]=(x%10)+48;
		else s[top]=(-(x%10)+48);
		x/=10;
	}while(x);
	while(top){pt(s[top]);top--;}
} 
ll num[1919];
ll ans=0;
signed main(){
	ll n=read();
	int k=read();
	for(register int i=k;i<=64;i++)
		num[i]=0;
	//num[i]代表x^a 这种形式的数 被算了几次 
	for(register int i=k;i<=64;i++){
		//pow(x,y) = x^y
		//pow(x,0.5) = sqrt(x)
		ll v=floor(pow(n,1.0/i)-1);
		int d=1-num[i];
		ans+=v*d;
		for(int j=i;j<=64;j+=i)
			num[j]+=d;
	}
	print(ans+1);
	return 0;
}

2023/5/2 09:20
加载中...