Page 2 of 3
Posted: Fri Feb 17, 2006 5:05 pm
by yogeshgo05
hi,
uva g++ compilers are little compact in header files & also this compiler
does not pull some header file if not included as in normal windows compilers ...
are the functions ecvt() ,gcvt() ... converting double to string are present in uva compiler
........
Posted: Fri Feb 17, 2006 7:24 pm
by mf
When I submit a C program, which calles [fge]cvt(), it compiles, so I guess, the answer to your question should be "yes".
But I have no idea, why the same program, submitted as a C++ source doesn't compile.
You can use sprintf() to convert double to a string instead.
Posted: Fri Feb 17, 2006 7:33 pm
by yogeshgo05
yes i think its better of using sprintf in order to convert double to string
but there is other logic i suppose ie
log(n)+1 gives number of digits of number n .. i want to no brother
that is this logic works
any way thanks man.....
1
Posted: Tue Feb 28, 2006 10:40 am
by tmdrbs6584
Hi logic
Bye logic
10219 - number of digits
Posted: Wed Aug 09, 2006 1:25 pm
by Donotalo
please help me! how to calculate number of digits of the result n*m? where n and m are integers.
Posted: Thu Aug 10, 2006 3:28 am
by Observer
Use logarithms ?!

What is the Range
Posted: Thu Oct 12, 2006 9:52 am
by Towhid
Can anyone tell me the maximum value for n???????

Re: What is the Range
Posted: Thu Oct 12, 2006 10:21 am
by helloneo
Towhid wrote:Can anyone tell me the maximum value for n???????

I don't know.. but possibly very big.. but surely fit in 32bit signed integer..
Posted: Thu Oct 12, 2006 12:25 pm
by asif_rahman0
HINTS:
think about
log. We can find the number of digit by log(10 base, not ln).
Ex: if log(12334), then we get 4.
Finally the formula will be
Posted: Tue Oct 16, 2007 7:00 am
by himanshu
The judge gives me Run Time Error for the following code :-
Code: Select all
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
long double logNfactorial(unsigned long int n)
{
//static to reuse past stored results
static vector<long double> logNf(2, 0);
for(int i = logNf.size(); i <= n; i++)
logNf.push_back(logNf[i-1] + log10(i));
return logNf[n];
}
int main()
{
unsigned long int n, k;
while(cin >> n >> k)
cout << (unsigned long int)
ceil(logNfactorial(n)-logNfactorial(k)-logNfactorial(n-k))
<< endl;
return 0;
}
For a large value I get Abort as output
Code: Select all
% ./a.out
999999 999
3430
99999999 9999
Abort
Posted: Tue Oct 16, 2007 9:17 am
by rio
I think the static vector is causing memory over flow or something.
Anyway, you don't need the vector at all.
----
Rio
Re: 10219 - Find the Ways !
Posted: Thu Sep 11, 2008 10:33 am
by pipo
hi..
I got WA several times.. but I don't really know... why WA ?? help me please..
Code: Select all
cutted after AC..
I just replaced data type from double to long double... :-?
thanks in advance...
10219 why time limit exit ?help me pleaseeeee
Posted: Sat Jul 31, 2010 9:01 am
by @mjad
Code: Select all
#include<iostream.h>
///using namespace std;
unsigned long int fact(int n);
int main()
{
int result[10000],carry,n,index;
while(cin>>n)
{
cout<<"\n";
if(n>1000)
continue;
cout<<fact(n)<<"\n\n";
}
return 0;
}
unsigned long int fact(int n)
{
int result[10000],carry,index;
unsigned long int sum=0;
result[0]=1;
index=carry=0;
if(n>1)
{
for(int i=2;i<=n;i++)
{
for(int j=0;j<=index;j++)
{
carry+=result[j]*i;
result[j]=carry%10;
carry/=10;
}
if(carry!=0)
{
do
{
result[++index]=carry%10;
carry/=10;
}while(carry!=0);
}
}
}
//cout<<n<<"! \n";
for(int i=index;i>=0;i--)
{
//cout<<result[i];
sum+=result[i];
}
//cout<<"\n";
return sum;
}
most of the problem, i get time limit exit please help me
about TLE please
Re: 10219 why time limit exit ?help me pleaseeeee
Posted: Sat Jul 31, 2010 11:55 am
by sohel
Why are you creating new threads for a problem whose discussions already exists!!
Don't create a new thread. Make your post in an existing one.
--and also use Code tags, when posting your code.
Re: 10219 why time limit exit ?help me pleaseeeee
Posted: Sat Jul 31, 2010 12:44 pm
by @mjad
thanks for reply..
i am really sorry for mistake,
after all i am a new user
no such mistake would happen in future
now help me please