QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#847696#9962. Diminishing FractionszyzzyhWA 7ms10720kbPython3593b2025-01-08 10:01:102025-01-08 10:01:10

Judging History

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

  • [2025-01-08 10:01:10]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:10720kb
  • [2025-01-08 10:01:10]
  • 提交

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}")
    
    return ''.join(result)

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

if __name__ == "__main__":
    main()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 10720kb

input:

2
3
6

output:

1/1-1/21/3
1/1-1/21/3-1/41/5-1/6

result:

wrong answer Denominator = 21 is out of range [1..3]