ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1044. Lucky Tickets. Easy!

get answer 669 for n = 4
Posted by hrushikesh 21 May 2005 22:37
Hello, my program does this:

i find the number of numbers with sum S and number of digits n/2, and store it in position SUM[S]
The total number of solutions is summation of SUM[S]*SUM[S] over all possible S

But I get the answer 669 in this case....where am I wrong?

Here's my code:
main()
{
 int N , sums[100] , end , t , t2 , cursum , total = 0;
 scanf("%d" , &N);
 for(t = 0 ; t <= 36 ; t++)
  sums[t] = 0;
 end = pow(10 , N / 2);
 for(t = 0 ; t < end ; t++)
 {
  cursum = 0;
  t2 = t;
  while(t2 > 0)
  {
   cursum += t2 % 10;
   t2 /= 10;
  }
  sums[cursum]++;
 }
 for(t = 0 ; t <= 36 ; t++)
  total += sums[t] * sums[t];
 printf("%d" , total);
}
Re: get answer 669 for n = 4
Posted by Fokysnik 1 Aug 2006 13:59
for n=4 answer is 670.
one more ticket you didn't count is 0000
Re: get answer 669 for n = 4
Posted by Zhasulan 18 Nov 2008 00:01
i have same problem,
but i fixed it
problem is in function pow:
pow(10,2) returns 99
::))) (stupid problem with pow)
do it with your hands:))
Re: get answer 669 for n = 4
Posted by Komarov Dmitry [Pskov SPI] 15 Nov 2009 01:12
use powl(long, long) from <math.h>

Edited by author 15.11.2009 01:12