sdnu1205.Factorial !

来源:互联网 发布:如何删除mac系统 编辑:程序博客网 时间:2024/06/03 23:00

1205.Factorial !
Time Limit: 1000 MS    Memory Limit: 32768 KB
Total Submission(s): 233    Accepted Submission(s): 48
Description
Your task is to Calculate  ” X !“(0<=X<=15)
Input
The input will consist of a series of pairs of integers X.
Output
For each input integers you should output X! one line,and followed by a blank line.
Sample Input
1
2
Sample Output
1

2
Hint

Source
Sunshine

#include<cstdio>#include<algorithm>#include<iostream>#include<cmath>#include<iomanip>#include<cstring>using namespace std;int main(){    int x,i;    long long s;    while(scanf("%d", &x)!=EOF)    {        s=1;        for(i=1; i<=x; i++){            s*=i;        }        printf("%lld\n\n", s);    }    return 0;}

注意阶乘!!!!用int会超的!!!! int 32767
因为这个wa了3次。。。绝望。。。

原创粉丝点击