2014年山东省第五届ACM大学生程序设计竞赛 E. Factorial

Factorial

Time Limit: 2000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

Homelesser hates mathematics. He cannot even do addition and subtraction, not to mention computing factorial. He asks Cainiao2hao for help. Cainiao2hao is always busy solving more difficult problems. And now, please help Homelesser to compute factorial. If you cannot do it well, Cainiao2hao will think you are as fool as Homelesser.
 

输入

The first line contains only one integer T (T is about 10) indicates the number of test cases. For each case there are one integer n (0 ≤ n ≤ 10).
 

输出

One line for each case specifying the factorial of n.
 

示例输入

2
4
3

示例输出

24
6

提示

 

来源

2014年山东省第五届ACM大学生程序设计竞赛

示例程序

 
  • #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int main()
    {
        int t,n,i,sum;
        cin>>t;
        while(t--)
        {
            sum=1;
            cin>>n;
            for(i=1;i<=n;i++)
            {
                sum*=i;
            }
            cout<<sum<<endl;
        }
        return 0;
    }
     
    
    
    
    /**************************************
    	Problem id	: SDUT OJ 2881 
    	User name	: mxjr130326刘继国 
    	Result		: Accepted 
    	Take Memory	: 460K 
    	Take Time	: 0MS 
    	Submit Time	: 2014-06-01 15:06:29  
    **************************************/


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值