QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#847696 | #9962. Diminishing Fractions | zyzzyh | WA | 7ms | 10720kb | Python3 | 593b | 2025-01-08 10:01:10 | 2025-01-08 10:01:10 |
Judging History
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]