HDU4551
简单。
/*
简单题
*/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<math.h>
using namespace std;
typedef long long ll;
//typedef __int64 int64;
const int maxn = 105;
const int inf = 0x7fffffff;
const double pi=acos(-1.0);
const double eps = 1e-8; int gcd( int a,int b ){
int r;
while( b ){
r = a%b;
a = b;
b = r;
}
return a;
} int lcm( int a,int b,int Gcd ){
return a*b/Gcd;
} int JudgeYear( int y ){
if( (y%400==0)||(y%4==0&&y%100!=0) )
return true;
else
return false;
} int JudgeMonth( int m ){
if( m==1||m==3||m==5||m==7||m==8||m==10||m==12 )
return true;
else
return false;
} int main(){
int T;
scanf("%d",&T);
int Case = 1;
while( T-- ){
printf("Case #%d: ",Case++);
int a,b,y;
scanf("%d%d%d",&a,&b,&y);
int ans = 0;
int m,d;
int ans1,ans2;
for( m=1;m<=12;m++ ){
for( int d=1;d<=31;d++ ){
if( m==2&&JudgeYear( y )==true&&d>=30 ) break;//闰年29days
if( m==2&&JudgeYear( y )==false&&d>=29 ) break;//平年28days
if( JudgeMonth(m)==false&&d>=31 ) break;
if( gcd( m,d )==a&&lcm( m,d,a )==b ){
ans++;
ans1 = m;
ans2 = d;
}
}
}
if( ans>1 ) printf("1\n");
else if( ans<1 ) printf("-1\n");
else printf("%d/%02d/%02d\n",y,ans1,ans2);
}
return 0;
}
HDU4551的更多相关文章
随机推荐
- Nginx 变量漫谈(六)
Nginx 内建变量用在“子请求”的上下文中时,其行为也会变得有些微妙. 前面在 (三) 中我们已经知道,许多内建变量都不是简单的“存放值的容器”,它们一般会通过注册“存取处理程序”来表现得与众不同, ...
- JVM的生命周期——JVM之二
一.首先分析两个概念 JVM实例和JVM执行引擎实例 (1)JVM实例对应了一个独立运行的java程序——进程级别 一个运行时的Java虚拟机(JVM)负责运行一个Java程序. 当启动一个Java程 ...
- LogLog
https://github.com/rsyslog https://github.com/beave/sagan http://www.securitywarriorconsulting.com/l ...
- 在WPF中自定义你的绘制(五)
原文:在WPF中自定义你的绘制(五) 在WPF中自定义你的绘制(五) ...
- Android开发之ExpandableListView扩展(BaseExpandableListAdapter的使用)(完整版)
Android开发之ExpandableListView扩展(BaseExpandableListAdapter的使用)(完整版)
- FPGA的SPI从机模块实现
一. SPI总线协议 SPI(Serial Peripheral Interface)接口,中文为串行外设接口.它只需要3根线或4根线即可完成通信工作(这里讨论4根线的情况). ...
- 我(webabcd)的文章索引
[最后更新:2014.08.28] 重新想象 Windows Store Apps 系列文章 重新想象 Windows 8 Store Apps 系列文章 重新想象 Windows 8 Store A ...
- hdu 1150 Machine Schedule hdu 1151 Air Raid 匈牙利模版
//两道大水……哦不 两道结论题 结论:二部图的最小覆盖数=二部图的最大匹配数 有向图的最小覆盖数=节点数-二部图的最大匹配数 //hdu 1150 #include<cstdio> #i ...
- hdu 5562 Clarke and food(贪心)
Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke turned i ...
- 九度OJ 题目1371:最小的K个数
题目描述: 输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,. 输入: 每个测试案例包括2行: 第一行为2个整数n,k(1< ...