题解 | #阶乘#

阶乘

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

#include <iostream>
using namespace std;
typedef long long LL;//应对超过32位的n!
LL jiechen(int n){
    LL mul=1;
    for(int i=n;i>=1;i--){
        mul*=i;
    }
    return mul;
}
int main() {
    int m;
    cin>>m;
    int arr[m];
    LL ans=0;
    for(int i=0;i<m;i++){
        cin>>arr[i];
    }
    for(int i=0;i<m;i++){
        ans=jiechen(arr[i]);
        cout<<ans<<endl;
}
return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

10-27 02:29
已编辑
门头沟学院 嵌入式工程师
牛客72783561...:简历不是这么写的,你这两个项目只说了用到了什么技术,却没说取得了什么成果,在我看来这就是你自己做的一个demo,没有价值。你为什么不写你电赛国二的那个项目?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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