程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Blue Bridge Cup basic exercise leap year judgment python|csdn creation punch in

編輯:Python

Blue Bridge Cup Based on practice Leap year judgment python

  • Resource constraints
  • Problem description
  • Input format
  • Output format
  • The sample input
  • Sample output
  • The sample input
  • Sample output
  • Data scale and agreement
  • Implementation code
  • matters needing attention

Resource constraints

The time limit :1.0s Memory limit :256.0MB

Problem description

Given a year , Judge whether this year is a leap year .

When one of the following conditions is satisfied , This year is a leap year :

  1. The year is 4 Instead of 100 Multiple ;

  2. The year is 400 Multiple .

Other years are not leap years .

Input format

Input contains an integer y, Represents the current year .

Output format

Output one line , If a given year is a leap year , The output yes, Otherwise output no.

The sample input

2013

Sample output

yes

The sample input

2016

Sample output

no

Data scale and agreement

1990 <= y <= 2050

Implementation code

y=int(input())
if y%400==0:
print('yes')
else:
if y%4==0:
if not(y%100==0):
print('yes')
else:
print('no')
else:
print('no')

matters needing attention

Leap year judgment is transformed into a mathematical problem to meet 1. The year is 4 Instead of 100 Multiple ;2. The year is 400 Multiple . The problem of two conditions .
Pay attention to case when outputting .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved