CSES - Datatähti 2023 alku - Results
Submission details
Task:Kertoma
Sender:maweiyin24562
Submission time:2022-11-09 22:19:42 +0200
Language:C++17
Status:COMPILE ERROR

Compiler report

input/code.cpp:76:14: error: 'll' was not declared in this scope; did you mean 'ld'?
   76 | ld LgStiring(ll n){
      |              ^~
      |              ld
input/code.cpp: In function 'int main()':
input/code.cpp:98:9: error: 'll' was not declared in this scope; did you mean 'ld'?
   98 |         ll l=1,r=Border,mid;
      |         ^~
      |         ld
input/code.cpp:99:15: error: 'l' was not declared in this scope
   99 |         while(l<r){
      |               ^
input/code.cpp:99:17: error: 'r' was not declared in this scope
   99 |         while(l<r){
      |                 ^
input/code.cpp:100:17: error: 'mid' was not declared in this scope
  100 |                 mid=l+(r-l)/2;
      |                 ^~~
input/code.cpp:101:29: error: 'LgStiring' cannot be used as a function
  101 |                 if(LgStiring(mid)>sum){
      |                    ~~~~~~~~~^~~~~
input/code.cpp:108:15: error: 'mid' was not declared in this scope
  108 |         cout<<mid<<endl;
      |...

Code

#include<bits/stdc++.h>
using namespace std;
struct num{
	int d[1010];
	int cnt; 
	void upgrade(){
		d[0]++;
		int i=0;
		while(d[i]>=10){
			d[i]=0;
			d[i+1]++;
			i++;
			cnt=max(cnt,i+1);
		}
	}
	void Init(int i){
		memset(d,0,sizeof(d));
		cnt=0;
		while(i){
			d[cnt]=i%10;
			cnt++;
			i/=10;
		}
	}
	void print(){
		for(int i=cnt-1;i>=0;i--){
			cout<<d[i];
		}
		cout<<endl;
	}
};
num times(num x,num y){
	num nd;
	nd.cnt=0;
	memset(nd.d,0,sizeof(nd.d));
	for(int i=0;i<x.cnt;i++){
		for(int j=0;j<y.cnt;j++){
			nd.d[i+j]+=x.d[i]*y.d[j];
		}
	}
	int len=x.cnt+y.cnt-1;
	for(int i=0;i<len;i++){
		if(nd.d[i]>=10){
			nd.d[i+1]+=nd.d[i]/10;
			nd.d[i]%=10; 
		}
	}
	if(nd.d[len]!=0){
		nd.cnt=len+1;
	}
	else{
		nd.cnt=len;
	}
	return nd;
}
struct lst{
	int d[10];
};
lst aim;
bool cmp(num a,lst b){
	int alst[10];
	memset(alst,0,sizeof(alst));
	for(int i=0;i<a.cnt;i++){
		int now=a.d[i];
		alst[now]++;
	}
	for(int i=0;i<10;i++){
		if(alst[i]!=b.d[i]){
			return false;
		}
	}
	return true;
}
num n,tmr;
typedef long double ld;
ld LgStiring(ll n){
	ld N=ld(n);
	return ll(0.5*(log10(2*Pi)+log10(N))+N*log10(N/E))+1;
}
int sum;
//6 3 2 1 2 1 1 0 2 0
int main(){
	for(int i=0;i<10;i++){
		cin>>aim.d[i];
		sum+=aim.d[i];
	}
	if(sum>=100010)goto G;
	n.Init(1);
	n.cnt=1;
	tmr.cnt=1;
	while(!cmp(n,aim)){
		tmr.upgrade();
		n=times(n,tmr);
	}
	tmr.print();
	return 0;
	G:
	ll l=1,r=Border,mid;
	while(l<r){
		mid=l+(r-l)/2;
		if(LgStiring(mid)>sum){
			r=mid;
		}
		else{
			l=mid+1;
		}
	}
	cout<<mid<<endl;
	return 0;
}