Please read the new rule regarding the restriction on the use of AI tools. ×

help!

Revision en1, by nilsilu95, 2015-06-18 22:58:59

why my code gives warning "Please do not use the %lld (or similar) specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator. Press button to submit the solution."

and also gives wa for n=10**9?My code in my computer gives ans as 8888888899 but in site, it is 8888888898?

#include <bits/stdc++.h>  
using namespace std;  
#define lli long long int
const int MAX=1e9+7;
lli solve(lli n){
	lli sz=log10(n)+1;
	if(sz==1)return n;
	lli ans=9+(n-pow(10,sz-1)+1)*sz;
	for(int i=sz-1;i>1;i--){
		ans+=9*i*pow(10,i-1);
	}
	return ans;
}
int main()  
{  
  
		lli n;
		cin>>n;
    	cout<<solve(n)<<"\n";
  	return 0;  
}  
Tags none

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English nilsilu95 2015-06-18 22:58:59 725 Initial revision (published)