10219 - Find the ways !
Moderator: Board moderators
-
- New poster
- Posts: 47
- Joined: Sun Nov 27, 2005 12:43 pm
-
- New poster
- Posts: 47
- Joined: Sun Nov 27, 2005 12:43 pm
-
- Learning poster
- Posts: 98
- Joined: Sat Jan 21, 2006 12:45 pm
- Location: Busan,Corea(Republic of)
1
Hi logic
Bye logic
Bye logic
Archaan
CAN YOU BEAT ME?
http://acm.uva.es/problemset/usersjudge.php?user=19788
AND,
http://acm.uva.es/problemset/submit.php
http://online-judge.uva.es/problemset/submit.php
SUBMIT AND GET AC!!!
CAN YOU BEAT ME?
http://acm.uva.es/problemset/usersjudge.php?user=19788
AND,
http://acm.uva.es/problemset/submit.php
http://online-judge.uva.es/problemset/submit.php
SUBMIT AND GET AC!!!
10219 - number of digits
please help me! how to calculate number of digits of the result n*m? where n and m are integers.
![Image](http://img157.imageshack.us/img157/295/donotalo2251522537ss3.png)
Use logarithms ?! ![:wink:](./images/smilies/icon_wink.gif)
![:wink:](./images/smilies/icon_wink.gif)
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Re: What is the Range
I don't know.. but possibly very big.. but surely fit in 32bit signed integer..Towhid wrote:Can anyone tell me the maximum value for n???????
-
- Experienced poster
- Posts: 209
- Joined: Sun Jan 16, 2005 6:22 pm
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
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
Code: Select all
floor(log[n])+1.
The judge gives me Run Time Error for the following code :-
For a large value I get Abort as output
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;
}
Code: Select all
% ./a.out
999999 999
3430
99999999 9999
Abort
Re: 10219 - Find the Ways !
hi..
I got WA several times.. but I don't really know... why WA ?? help me please..
thanks in advance...
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... :-?
10219 why time limit exit ?help me pleaseeeee
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;
}
about TLE please
Last edited by @mjad on Sat Jul 31, 2010 12:40 pm, edited 1 time in total.
Re: 10219 why time limit exit ?help me pleaseeeee
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.
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
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
i am really sorry for mistake,
after all i am a new user
no such mistake would happen in future
now help me please