简单。

/*
简单题
*/
#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的更多相关文章

随机推荐

  1. [转]linux下IPTABLES配置详解

    如果你的IPTABLES基础知识还不了解,建议先去看看.开始配置我们来配置一个filter表的防火墙.(1)查看本机关于IPTABLES的设置情况[root@tp ~]# iptables -L -n ...

  2. JavaScript声音播放

    方式一: /** * 播放音频(Chrome.opera)支持 * @param file:支持 rm,mid,wav */ function playAudio(file) { var embed= ...

  3. Web scraping with Python (part II) « Jean, aka Sig(gg)

    Web scraping with Python (part II) « Jean, aka Sig(gg) Web scraping with Python (part II)

  4. virtualbox 复制多个虚拟机 (宿主机redhat)

    我用VirtualBox做了一个winxp虚拟镜像. 想实现不重新安装而直接复制几个,也就是同时装载几个虚拟机. 但是直接复制已安装好机子的vdi文件,系统会报uuid已存在的错误. 所以,就需要修改 ...

  5. Windows下通过脚本快速修改IP地址

    Windows下通过脚本快速修改IP地址 如果通过Windows的网络属性修改Ip/网关,真是太麻烦了. 经常要切换ip,所以我写了两个脚本: c:\办公室.bat netsh interface i ...

  6. ORACLE AWR概述及生成AWR报告

    1.Overview of the Automatic Workload Repository The Automatic Workload Repository (AWR) collects, pr ...

  7. Unity3D Object.DontDestroyOnLoad 备忘

    初学Untiy3D,记录备忘. public static void DontDestroyOnLoad(Object target); Makes the object target not be ...

  8. css3实现图片遮罩效果鼠标hover以后出现文字

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  9. SQL————高级查询

    高级查询 --连接查询 select * from 表1,表2 ————形成笛卡尔积 select * from 表1,表2 where 表1.主键=表2.外键  ————主外键位置可以互换 --jo ...

  10. c#变量在for循环内声明与外的区别

    1.这样写是错误的 #region 有这样的一个字符串类型的数组{"老杨","老苏","老马","老牛"};要求 变换成 ...