题解 | #阶乘#

阶乘

https://www.nowcoder.com/practice/4b8f5815c7cd40ab851c24fc5de70fa4

#include <iostream>
using namespace std;
int main() {
    int n;cin>>n;
    while(n--){
        int tmp;cin>>tmp;
        long long res=1;
        for(int i =1;i<=tmp;i++)
            res*=i;
        cout<<res<<endl;
    }
}
// 64 位输出请用 printf("%lld")

要用到long long

全部评论

相关推荐

点赞 评论 收藏
分享
06-05 19:46
已编辑
武汉大学 后端
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务