ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1036. Счастливые билеты

help me for 1036
Послано galois 14 июн 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.
Послано Dinh Hong Minh 14 июн 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...
Послано Stefan Pochmann 14 июн 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.
Послано galois 16 июн 2001 15:21
Can you mail me your pascal code?
Re: help me for 1036
Послано Deian Lambov 30 ноя 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
>
>