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 1083. Factorials!!!

LOL!!! WA #1 but works correctly on my computer
Posted by Son1G 4 Jul 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
Posted by hatred 9 Jul 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
Posted by Aman 15 Sep 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
Posted by ToadMonster 15 Sep 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