题解:P5711 【深基3.例3】闰年判断
Dream_Stars · · 题解
犇犇里听说这道题可以写题解喵。
题目大意:
输入一个年份,判断其是不是闰年喵,是闰年的话输出
算法分析:
不知道闰年的概念戳这里喵。\
很显然,我们只需要分类讨论
具体的话可以看代码实现喵。
代码展示:
# include <bits/stdc++.h>
# define ll long long
# define int long long
# define rint register int
long long read(){long long s = 0 , w = 0; char c = getchar(); while(!isdigit(c)) w |= (c == '-') , c = getchar(); while(isdigit(c)) s = (s << 1) + (s << 3) + (c ^ 48) , c = getchar(); return w ? -s : s;}
void write(long long x){if(x < 0) putchar('-') , x = ~ (x - 1); if(x > 9) write(x / 10); putchar(x % 10 | 48);}
void writesp(long long x){write(x) , putchar(' '); }
void writeln(long long x){write(x) , putchar('\n');}
using namespace std;
long long n;
signed main() {
n = read();//输入喵。
if(n % 4 == 0 && n % 100 != 0 || n % 400 == 0) write(1);
else write(0);//判断是否闰年即可喵。
return 0;
}