gpt4 book ai didi

python - Codechef 为本地运行的程序给出了错误的答案

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:43:48 29 4
gpt4 key购买 nike

问题陈述:

According to Gregorian Calendar, it was Monday on the date 01/01/2001. If any year is input, Write a program to display what is the day on the 1st January of this year.

Input

The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer year.

Output

Display the day on the 1st January of that year in lowercase letter.

Constraints

1 ≤ T ≤ 1000

1900≤ A,B,C ≤2500

Example

Input

3

1994

1991

2014

Output

saturday

tuesday

wednesday

我提交的解决方案:

import datetime
test = input("Enter no. of test cases ")
while (test):
year = input("Enter the year ")
day = datetime.date(int(year),1,1).strftime("%A")
print (day.lower())
test = int(test)-1

当我在本地运行时,一切正常。输出与测试用例中给出的相同。为什么在 Codechef 上给出错误答案?

最佳答案

你不需要提示输入,事实上它会在几乎所有的在线评委上给你错误的答案。以下代码给出了正确答案。

import datetime
test = int(input())
while test:
year = input()
day = datetime.date(int(year),1,1).strftime("%A")
print(day.lower())
test -= 1

关于python - Codechef 为本地运行的程序给出了错误的答案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32069975/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com