为什么这种求位数的代码得不到正确答案
查看原帖
为什么这种求位数的代码得不到正确答案
465055
1004779564bzbjj楼主2023/10/2 11:46
#include<bits/stdc++.h>
using namespace std;
long long ed[51],p,ans,t=2;
int main(){
	cin>>p;
	for(int i=1;i<=p;i++){
		t*=2;
		if(t>=100000){
			t/=10;
			ans++;
		}
		//if(i%1000==0)
		//printf("%d ",t);
		//cout<<t<<" ";
		//for(int j=1;j<=ans;j++)cout<<"0";
		//cout<<endl;
	}
	cout<<ans+5<<endl;
	printf("%d\n",(int)(log10(2)*p+1));
	return 0;
}

in:114514 out:34473 34473

in:233333 out:70240 70241

in:666666 out:200685 200687

in:1919810 out:577914 577921

2023/10/2 11:46
加载中...