http://ac.jobdu.com/problem.php?pid=1179
不涉及大数,所以简单阶乘就好,结果保存在long long 型数据
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
long long JIEC(long long x)
{
if (x==1)
{
return x;
}
else
return x*JIEC(x-1);
}
int main()
{
long long x,i,j;
while (scanf("%lld",&x)!=EOF)
{
long long y1=0,y2=0;
if (x%2==0)
{
for (i=x;i>=2;i-=2)
{
y2+=JIEC(i);
}
for (i=x-1;i>=1;i-=2)
{
y1+=JIEC(i);
}
}
else
{
for (i=x;i>=1;i-=2)
{
y1+=JIEC(i);
}
for (i=x-1;i>=2;i-=2)
{
y2+=JIEC(i);
}
}
printf("%lld %lld\n",y1,y2);
}
return 0;
}