简单。

/*
简单题
*/
#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. Repository仓储 UnitofWork

    Repository仓储 UnitofWork 目录索引 [无私分享:ASP.NET CORE 项目实战]目录索引 简介 本章我们来创建仓储类Repository 并且引入 UnitOfWork 我对 ...

  2. Linux进程间通信——信号集函数

    一.什么是信号 用过Windows的我们都知道,当我们无法正常结束一个程序时,可以用任务管理器强制结束这个进程,但这其实是怎么实现的呢?同样的功能在Linux上是通过生成信号和捕获信号来实现的,运行中 ...

  3. hdu 1599 find the mincost route_最小环

    #include <iostream> #include<cstdio> using namespace std; #define N 110 #define INF 0xff ...

  4. windows7旗舰版下载出现蓝屏代码50怎么办?

    windows7旗舰版下载出现蓝屏代码50怎么办?电脑蓝屏BCCode:50. 问题事件名称: BlueScreen OS 版本: 6.1.7601.2.1.0.256.1 区域设置 ID: 2052 ...

  5. 如何用SQL SERVER 2005连接SQL SERVER 2008

    原先使用sql server 2005数据库,后来由于工作需要升级为sql server 2008 开发版,升级过程很简单,基本没有什么问题 下面主要说说,如何使用sql server 2005 st ...

  6. spring boot 中文文档

    https://qbgbook.gitbooks.io/spring-boot-reference-guide-zh/content/VII.%20Spring%20Boot%20CLI/index. ...

  7. 使用FileSystemWatcher捕获系统文件状态

    源代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Sys ...

  8. 自定义按照index和key访问的List

    List<T>用起来比较方便,但是有时候要按照Index来访问List中的对象有些繁琐,所以想是不是扩展一下,既能按照Index来访问,又能按照Key访问. 实现方法: public cl ...

  9. Database name和SID

    http://docs.oracle.com/cd/B19306_01/install.102/b15667/rev_precon_db.htm#i1027493 The Oracle Databas ...

  10. ES6笔记① var 和 let的区别

    let 和 var的区别    答:不同点在于作用域 1.(全局下)首先  let关键字声明的变量是这样写会导致错误. let声明的变量类似于”本地变量“,函数内如何不重新声明,还是会被改变 var ...