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

Обсуждение задачи 1083. Факториалы!!!

LOL!!! WA #1 but works correctly on my computer
Послано Son1G 4 июл 2011 20:12
Problem is input of data! How should i fix it?
Code:
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

int n, k;
string s;

int main() {
 cin >> n; cin >> s;
 int i;
 i=0; k=0;
 while(s[i]=='!') {
    k++;
    i++;
 }

 long long a, temp;

 a=1; i=0;
 if(n%k!=0) {
    while(temp!=n%k) {
       temp=n-i*k;
       a*=temp;
       i++;
    }
 } else
 if(n%k==0) {
    while(temp!=k) {
       temp=n-i*k;
       a*=temp;
       i++;
    }
 }

 cout << a << endl;

 system("pause");
 return 0;
}
Re: LOL!!! WA #1 but works correctly on my computer
Послано hatred 9 июл 2011 21:23
try to delete system("pause") may be it puts some text into stdout
Re: LOL!!! WA #1 but works correctly on my computer
Послано Aman 15 сен 2016 04:54
Remove system("pause"); statement from your code. In this program we have to do special handling of big integer variables as none of the basic data types of C++ can store very large numbers; Here we have to store numbers in array or we can use Big Integer class in case of Java program.
http://www.techcrashcourse.com/2015/05/c-programming-language-data-types.html
http://www.techcrashcourse.com/2015/05/c-programming-language-variables.html
http://www.techcrashcourse.com/2016/04/java-example-programs.html

Edited by author 15.09.2016 04:55

Edited by author 15.09.2016 04:55
Re: LOL!!! WA #1 but works correctly on my computer
Послано ToadMonster 15 сен 2016 18:45
> In this program we have to do special handling of big integer variables

Are you sure?
20! ~= 2E18
signed long long limit = 2^63-1 ~= 9E18

P.S.
Article http://www.techcrashcourse.com/2015/05/c-programming-language-data-types.html is ... weird.
Table is for some 16-bit compiler. Typical compilers now are 32bit - 64bit.
No long long at all in the table.
Long double - 10 bytes and bigger rabnge or the same range with double so 8 bytes?



Edited by author 15.09.2016 18:57