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

Общий форум

1048 - Super long sums... HELP
Послано Nephtali Garrido 19 июл 2005 01:51
I still have troubles with this program, please help me, i don´t found the error.

Here is my code

#include <iostream>
using namespace std;

unsigned long int m, c;
int *v, *v2;

int main()
{     cin>>m;
      v=new int[m+5];
      v2=new int[m+5];
      for(c=0;c<m;c++)
        cin>>v[c]>>v2[c];
      c=m-1;
      while(c>0)
      {  v[c]+=v2[c];
         if(v[c]>=10)
         { v[c-1]+=v[c]/10;
           v[c]%=10;
         }
         c--;
      }
      v[0]+=v2[0];
      for(c=0;c<m;c++)
       cout<<v[c];
      delete [] v;
      delete [] v2;
      return 0;
}

beforehand thanks...
I see you have MLE (+)
Послано qwerty 19 июл 2005 02:01
Of course you get Memory limit: You use 2 arrays, where each element int (4 bytes). If there are 1000000 digits, than You need 4000000 bytes, that grather than 1 MB. Try to think out any trick. Even use array of char, or ... Try to solve this easy problem yourself :)
Good Luck
Re: I see you have MLE (+)
Послано Nephtali Garrido 19 июл 2005 02:10
Thanks, i´m working in that, I just want to know the better way to do it.

Thanks qwerty, I still work !!
I see you can not to do it... (+)
Послано qwerty 19 июл 2005 02:33
Try to store in every ceil of your array not 1 but more digits, i.e. use not 10-based nubmers, but 1000000-based. Or think more carefully and think out algo without arrays.
Thats all.
And try to solve other, more simple problems. For example 1000(A+B), or 1068.
Good Luck.
Ok, I try first other programs...
Послано Nephtali Garrido 20 июл 2005 06:56
Ok, I´ll try first other programs...
Послано Nephtali Garrido 20 июл 2005 06:59
Ok, I´ll take your advice.

I will try other programs, because i have the idea but something is missing :p

Thanks a lot, I appreciate your help
If you want, I'll help you more. (+)
Послано qwerty 20 июл 2005 14:49
My e-mail: barssimfi@mail.ru
If you know russian, it is very good. I can help you, I can correct your codes and find some mistakes in this easy problems.