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

What's Wrong ! ACM Timus system wrote me WA № Test 1 . Can anybody help me?
Posted by Александр 16 Oct 2012 15:33
#include <stdio.h>

int fact(int n, int k){
    int res = 1;
    if (n == 0)
        return res;
    while (n > k) {
         res *= n;
         n -= k;
    }
    if (n % k)
        res *= (n % k);
    else
        res *= k;
    return res;
}

int main () {
    char sym;
    int n = 0;
    int symCount = 0;
    scanf("%d ", &n);
    while (scanf("%1[!]", &sym) == 1) {
            symCount++;
    }
    printf("%d\n", fact(n, symCount));
    return 0;
}