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

help me pls!
Posted by Levan 31 Dec 2015 12:04
what is wrong?

#include <iostream>
#include <cmath>
#include <map>
#include <vector>
using namespace std;

int main()
{
    int n;
    string str;
    cin >> n >> str;

    int k = str.size();
    int i = 0;
    int sum = 1;
    if(n % k == 0)
    {
        while(i != n / k)
        {
            sum *= n - k * i;
            i++;
        }
    }
    else
    {
        while(i != n / k + 1)
        {
            sum *= n - k * i;
            i++;
        }
        sum *= n % k;
    }

    cout << sum << endl;

    return 0;
}

Edited by author 31.12.2015 12:38
Re: help me pls!
Posted by ToadMonster 31 Dec 2015 12:50
It would be great if you stop searching telepathists and show error message.

Is it compilation error? Add "#include <string>" line.
Is it WA? Strange. Code looks working.
Is it any another error? Show it.
Re: help me pls!
Posted by Levan 31 Dec 2015 13:02
WA #10
Re: help me pls!
Posted by ToadMonster 31 Dec 2015 14:03
Some people suppose n can be 20 so int is not enough for sum.
Try to use long long sum.
Re: help me pls!
Posted by Levan 1 Jan 2016 19:33
WA #10
Re: help me pls!
Posted by ToadMonster 4 Jan 2016 15:01
Test:
5 !!!
answer 10, your answer 20
Re: help me pls!
Posted by Bu1bu1 13 Mar 2021 01:32
5!!!
here k=3,
5 isn't divisible by 3
so you have to multiply 5%3=2 with 5*(5-3)
so the answer is 5*2*2=20