QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#784359#5715. 幂次TaoRan100 ✓4ms3720kbC++141.1kb2024-11-26 14:45:502024-11-26 14:45:51

Judging History

你现在查看的是最新测评结果

  • [2024-11-26 14:45:51]
  • 评测
  • 测评结果:100
  • 用时:4ms
  • 内存:3720kb
  • [2024-11-26 14:45:50]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long 
#define pt putchar
using namespace std;
typedef long long ll;
const int N=100;
int read();
void write(int x);
int n,k;

int v[N],c[N];

int calc(int o){
	if(o==2){
		int v=sqrt((double)n)+10;
		while(v*v>n){
			v--;
		}
		return v;
	}
	for(int i=1;i<=n;i++){
		__int128 v=1;
		for(int j=1;j<=o;j++){
			v*=i;
		}
		if(v>n){
			return i-1;
		}
	}
	return -1;
}

signed main(){
	//freopen("ex_power5.in","r",stdin);
	n=read();k=read();
	if(k==1){
		write(n);return 0;
	}
	if(n==1){
		write(1);return 0;
	}
	int ans=0;
	for(int i=k;i<=60;i++){
		v[i]=calc(i)-1;
		int sc=0;
		for(int j=k;j<i;j++){
			if(i%j==0){
				sc+=c[j];
			}
		}
		//printf("%d:%lld %lld\n",i,sc,v[i]);
		c[i]=1-sc;
		ans+=v[i]*c[i];
	}
	write(ans+1);
	return 0;
}

int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-'){
			f=-1;
		}
		c=getchar();
	}
	while('0'<=c&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
void write(int x){
	if(x<0){
		pt('-');
		x=-x;
	}
	if(x>9){
		write(x/10);
	}
	pt(x%10+'0');
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 0ms
memory: 3488kb

input:

92 1

output:

92

result:

ok 1 number(s): "92"

Test #2:

score: 5
Accepted
time: 0ms
memory: 3536kb

input:

96 2

output:

12

result:

ok 1 number(s): "12"

Test #3:

score: 5
Accepted
time: 0ms
memory: 3588kb

input:

9383 3

output:

37

result:

ok 1 number(s): "37"

Test #4:

score: 5
Accepted
time: 0ms
memory: 3720kb

input:

9830 2

output:

124

result:

ok 1 number(s): "124"

Test #5:

score: 5
Accepted
time: 0ms
memory: 3648kb

input:

927700 3

output:

149

result:

ok 1 number(s): "149"

Test #6:

score: 5
Accepted
time: 0ms
memory: 3488kb

input:

972504 2

output:

1097

result:

ok 1 number(s): "1097"

Test #7:

score: 5
Accepted
time: 0ms
memory: 3612kb

input:

94345650 3

output:

605

result:

ok 1 number(s): "605"

Test #8:

score: 5
Accepted
time: 0ms
memory: 3616kb

input:

98811802 2

output:

10429

result:

ok 1 number(s): "10429"

Test #9:

score: 5
Accepted
time: 0ms
memory: 3652kb

input:

9328450690 3

output:

2541

result:

ok 1 number(s): "2541"

Test #10:

score: 5
Accepted
time: 0ms
memory: 3532kb

input:

9775065820 2

output:

101083

result:

ok 1 number(s): "101083"

Test #11:

score: 5
Accepted
time: 0ms
memory: 3716kb

input:

948459050000 3

output:

11116

result:

ok 1 number(s): "11116"

Test #12:

score: 5
Accepted
time: 0ms
memory: 3496kb

input:

993120563000 2

output:

1006727

result:

ok 1 number(s): "1006727"

Test #13:

score: 5
Accepted
time: 1ms
memory: 3592kb

input:

93781484300000 3

output:

49275

result:

ok 1 number(s): "49275"

Test #14:

score: 5
Accepted
time: 1ms
memory: 3616kb

input:

98250912400000 2

output:

9958807

result:

ok 1 number(s): "9958807"

Test #15:

score: 5
Accepted
time: 1ms
memory: 3592kb

input:

9272034040000000 3

output:

221661

result:

ok 1 number(s): "221661"

Test #16:

score: 5
Accepted
time: 1ms
memory: 3600kb

input:

9981231040000000 2

output:

100122721

result:

ok 1 number(s): "100122721"

Test #17:

score: 5
Accepted
time: 4ms
memory: 3672kb

input:

942817384000000000 3

output:

1016053

result:

ok 1 number(s): "1016053"

Test #18:

score: 5
Accepted
time: 4ms
memory: 3596kb

input:

987478897000000000 2

output:

994718860

result:

ok 1 number(s): "994718860"

Test #19:

score: 5
Accepted
time: 0ms
memory: 3528kb

input:

932205945000000000 2

output:

966488284

result:

ok 1 number(s): "966488284"

Test #20:

score: 5
Accepted
time: 4ms
memory: 3468kb

input:

992520149596833024 2

output:

997253882

result:

ok 1 number(s): "997253882"

Extra Test:

score: 0
Extra Test Passed