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!!!

Why WA on test #5?
Posted by Zelenska Yevgeniya VNTU 15 Mar 2011 21:38
#include <conio.h>
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main(){
long long n;
string s;
cin>>n;
cin>>s;
int f=1;
long long rez=n;
int i=1;
int k=s.size();
int zal = n % k;
if (zal==0) {
    rez=rez*k;
    while (f==1){
        if((n-i*k)>0){
            rez=rez*(n-i*k);
            i=i+1;
        } else if ((n-i*k)<=0) {
                   break;
               }
    }
} else if (n%k!=0) {
    zal=n%k;
    rez=rez*zal;
    while (f==1){
        if((n-i*k)!=zal){
            rez=(n-i*k)*rez;
            i=i+1;
        } else if ((n-i*k)==zal) {
                    break;
               }
    }
}
printf("%d",rez);
return 0;
}

Where is my mistake?