QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#847698#9962. Diminishing FractionszyzzyhWA 15ms10648kbPython3621b2025-01-08 10:02:222025-01-08 10:02:24

Judging History

你现在查看的是最新测评结果

  • [2025-01-08 10:02:24]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:10648kb
  • [2025-01-08 10:02:22]
  • 提交

answer

def solve(n):
    if n == 1:
        return "1/1"
    
    # 创建一个空列表来存放分数表达式
    result = []
    
    # 交替加减,尽量使结果尽量小
    for i in range(1, n+1):
        if i % 2 == 1:
            result.append(f"1/{i}")
        else:
            result.append(f"-1/{i}")
        result.append(' ')
    
    return ''.join(result)

def main():
    t = int(input())  # 读取测试用例的数量
    for _ in range(t):
        n = int(input())  # 读取每个测试用例的 n
        print(solve(n))  # 输出结果

if __name__ == "__main__":
    main()

详细

Test #1:

score: 0
Wrong Answer
time: 15ms
memory: 10648kb

input:

2
3
6

output:

1/1 -1/2 1/3 
1/1 -1/2 1/3 -1/4 1/5 -1/6 

result:

wrong answer Sums do not match for modulus 8809877585262195773