文章

67

粉丝

207

获赞

29

访问

38.2k

头像
阶乘2 题解:Python题解
P1416 华中科技大学机试题
发布于2024年10月7日 17:08
阅读数 251

while True:
    try:
        n = int(input())
        sum0 = 0
        sum1 = 0
        sum00 = 0
        sum01 = 0
        sum11 = 0
        sum10 = 0
        if n%2 ==0:
            for i in range(2,n+1):
                if i%2 != 0:
                    continue
                sum00 =1
                for j in range(1,i+1):
                    sum00 = sum00*j
                sum0 = sum0 + sum00
            for i in range(1,n):
                if i%2 == 0:
                    continue
                sum01 = 1
                for j in range(1,i+1):
                    sum01 = sum01*j
                sum1 = sum1 + sum01
            print(sum1, end=' ')
            print(sum0)
        else :
            for i in range(1, n + 1):
                if i % 2 == 0:
                    continue
                sum10 = 1
                for j in range(1, i + 1):
                    sum10 = sum10 * j
                sum0 = sum0 + sum10
            for i in...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发