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 1036. Lucky Tickets

help me for 1036
Posted by galois 14 Jun 2001 12:22
my solution is below,the system says WRONG ANSWER
please help me

#include "stdio.h"
unsigned long count(int n,int s)
{
    int i;
    unsigned long sum=0;
    if (n==1)
        if (s<=9)
            return 1;
        else
            return 0;
    for(i=0;i<=((s>9)?9:s);i++)
        sum+=count(n-1,s-i);

    return sum;
}

main()
{
    int n;
    int s;
    unsigned long result;
    unsigned long tmp;
    scanf("%d",&n);
    scanf("%d",&s);
    if ((s%2)==1)
        result=0;
    else
    {    tmp=count(n,s/2);
        result=tmp*tmp;
    }
    printf("%lu\n",result);
    return 0;
}
please mail to me
galois@kali.com.cn
Galois was died and I use Pascal. Sorry.
Posted by Dinh Hong Minh 14 Jun 2001 19:20
> my solution is below,the system says WRONG ANSWER
> please help me
>
> #include "stdio.h"
> unsigned long count(int n,int s)
> {
>     int i;
>     unsigned long sum=0;
>     if (n==1)
>         if (s<=9)
>             return 1;
>         else
>             return 0;
>     for(i=0;i<=((s>9)?9:s);i++)
>         sum+=count(n-1,s-i);
>
>     return sum;
> }
>
> main()
> {
>     int n;
>     int s;
>     unsigned long result;
>     unsigned long tmp;
>     scanf("%d",&n);
>     scanf("%d",&s);
>     if ((s%2)==1)
>         result=0;
>     else
>     {    tmp=count(n,s/2);
>         result=tmp*tmp;
>     }
>     printf("%lu\n",result);
>     return 0;
> }
> please mail to me
> galois@kali.com.cn
>
>
New webboard system, please...
Posted by Stefan Pochmann 14 Jun 2001 20:09
If you don't have anything to say, why wasting space
in the webboard? It's overcrowded anyway. I always have
to look over the subjects again and again and again.
I would be very happy if timus would install another
Webboard, just like that of acm.uva.es (hello admins?)
or something better...

Stefan Pochmann
Re: Galois was died and I use Pascal. Sorry.
Posted by galois 16 Jun 2001 15:21
Can you mail me your pascal code?
Re: help me for 1036
Posted by Deian Lambov 30 Nov 2001 09:31
An obvious error:
The result in the bigest test exceeds the c++'s long type.
You should implement and use long numbers in the solution.


> my solution is below,the system says WRONG ANSWER
> please help me
>
> #include "stdio.h"
> unsigned long count(int n,int s)
> {
>     int i;
>     unsigned long sum=0;
>     if (n==1)
>         if (s<=9)
>             return 1;
>         else
>             return 0;
>     for(i=0;i<=((s>9)?9:s);i++)
>         sum+=count(n-1,s-i);
>
>     return sum;
> }
>
> main()
> {
>     int n;
>     int s;
>     unsigned long result;
>     unsigned long tmp;
>     scanf("%d",&n);
>     scanf("%d",&s);
>     if ((s%2)==1)
>         result=0;
>     else
>     {    tmp=count(n,s/2);
>         result=tmp*tmp;
>     }
>     printf("%lu\n",result);
>     return 0;
> }
> please mail to me
> galois@kali.com.cn
>
>