简单。

/*
简单题
*/
#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. 利用Azure Backup备份和恢复虚拟机(2)

    虚拟机注册之后,下一步就是将他们添加为受保护的项,在菜单底部,单击"保护"按照提示选择需要保护的虚拟机     单击"下一步",在这个页面中需要选择配置虚拟机配 ...

  2. Windows服务安装完成后自动启动

    public ServiceInstaller() { //... Installer code here this.AfterInstall += new InstallEventHandler(S ...

  3. android 管理Bitmap内存 - 开发文档翻译

    由于本人英文能力实在有限,不足之初敬请谅解 本博客只要没有注明“转”,那么均为原创,转贴请注明本博客链接链接   Managing Bitmap Memory 管理Bitmap内存 In additi ...

  4. 我(webabcd)的文章索引

    [最后更新:2014.08.28] 重新想象 Windows Store Apps 系列文章 重新想象 Windows 8 Store Apps 系列文章 重新想象 Windows 8 Store A ...

  5. linux之SQL语句简明教程---UNION

    UNION 指令的目的是将两个 SQL 语句的结果合并起来.从这个角度来看, UNION 跟 JOIN有些许类似,因为这两个指令都可以由多个表格中撷取资料. UNION 的一个限制是两个 SQL 语句 ...

  6. C链表之创建简单静态链表

    C代码: #include<stdio.h> #include<stdlib.h> #include<malloc.h> //创建简单静态链表 typedef st ...

  7. hdu 1536 S-Nim_求sg值模版

    题意:给你很n堆石头,k代表你有k种拿法,然后给出没堆石头的数量,求胜负 直接套用模版 找了好久之前写的代码贴上来 #include<iostream> #include<algor ...

  8. gcc选项-g与-rdynamic的异同

    摘自http://www.tuicool.com/articles/EvIzUn gcc选项-g与-rdynamic的异同 gcc 的 -g ,应该没有人不知道它是一个调试选项,因此在一般需要进行程序 ...

  9. x/nfu-用gdb查看内存

    用gdb查看内存 2007-12-08 12:43 用gdb查看内存 格式: x /nfu <addr> 说明x 是 examine 的缩写 n表示要显示的内存单元的个数 f表示显示方式, ...

  10. VS2010中更改项目名称(转载)

    一.修改解决方案的名称:直接选择解决方案,右键重命名即可.