1 条题解

  • 0
    @ 2024-12-24 9:14:31

    C++ :

    #include <cstdio>
    using namespace std;
    int main ()
    {
    	long long s;		//long long的范围为-263~263-1,
    					    //int的-1019~1019略窄
    	int n;				//n不能定义为long long,否则for语句死循环
    	s=1;
    	scanf("%d",&n);
    	for (int i=1; i<=n ; ++i)	//当n=13时s超出long int的范围
    		s*=i;
    	printf("%lld\n",s);		//使用%d输出long long结果有误
    	return 0;
    }
    
    

    Python :

    # coding=utf-8
    s = int(input())
    for i in range(1,s,1):
        s=s*i
    print(s)
    
    • 1

    信息

    ID
    537
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者