URAL 1083. Factorials!!!

来源:互联网 发布:开源软件代码 编辑:程序博客网 时间:2024/05/16 06:52
 A simple math question, just scrab a simple answer:

#include <cstdio>
#include 
<iostream>

using namespace std;

int N = 0;
int K = 0;

long long result = 0;

void main()
{
    scanf(
"%d"&N);

    getchar();

    
while('!' == getchar())
    {
        
++K;
    }

    
if(N <= K)
    {
        printf(
"%d", N);
    }
else
    {
        
int end = N%K;

        result 
= 1;

        
for(;N!= end;N-=K)
        {
            result 
*= N;
        }

        
if(end)
        {
            result
*= end;
        }

        printf(
"%d", result);
    }
}
原创粉丝点击