博客
关于我
Codeforces B.Planet Lapituletti (模拟时间&镜像)(Round #705 Div.2)
阅读量:161 次
发布时间:2019-02-28

本文共 2084 字,大约阅读时间需要 6 分钟。

题意: 星球上的时间制度是每天h小时,每小时m分钟。告诉你现在的时间,需要你找到以后第一个镜像时间——指镜像翻转过后是正确的时间,例如05:11 -> 11:20是个正确时间。

思路:

n<=100组数据,每组的h,m都在100以内,可以直接暴力枚举。

①:首先判断其能够镜像翻转,即只含有0,1,2,5,8这几个数字。

②:判断其镜像翻转后的时间hh:mm是正确的(注意2和5的转换),即hh<h&&mm<m(其他的都不行,俺就是在这里错了呜呜)。

 

代码实现:

#include
#define endl '\n'#define null NULL#define ll long long#define int long long#define pii pair
#define lowbit(x) (x &(-x))#define ls(x) x<<1#define rs(x) (x<<1+1)#define me(ar) memset(ar, 0, sizeof ar)#define mem(ar,num) memset(ar, num, sizeof ar)#define rp(i, n) for(int i = 0, i < n; i ++)#define rep(i, a, n) for(int i = a; i <= n; i ++)#define pre(i, n, a) for(int i = n; i >= a; i --)#define IOS ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);const int way[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};using namespace std;const int inf = 0x3f3f3f3f;const double PI = acos(-1.0);const double eps = 1e-6;const ll mod = 1e9+7;const int N = 2e5 + 5;inline void read(int &x){ char t=getchar(); while(!isdigit(t)) t=getchar(); for(x=t^48,t=getchar();isdigit(t);t=getchar()) x=x*10+(t^48);}int t, h, m, x, y;bool ok(int x){ if(x<10){ if(x==0||x==1||x==2||x==5||x==8) return 1; else return 0; } else if(x==100) return 1; else{ int a = x/10, b = x%10, flag = 0; if(a==0||a==1||a==2||a==5||a==8) flag = 1; if((b==0||b==1||b==2||b==5||b==8)&&flag) return 1; else return 0; }}int fi(int x){ if(x==0||x==1||x==8) return x; //得到对应数字 if(x==2) return 5; if(x==5) return 2;}bool check(int a, int b){ if(!ok(a)||!ok(b)) return 0; //如果不可翻转 int flag = 0; if(b==100) x = 1; else x = fi(b%10)*10+fi(b/10); if(a==100) y = 1; else y = fi(a%10)*10+fi(a/10);// cout << "a: " << a << " b: " << b << endl;// cout << "x: " << x << " y: " << y << endl; if(x
> t; while(t --){ cin >> h >> m; int a, b; char c; cin >> a >> c >> b; for(; ; b ++){ if(b&&b%m==0) a ++;// cout << "check: " << check(a%h, b%m) << endl; if(check(a%h, b%m)) break; } } return 0;}

 

转载地址:http://vxdj.baihongyu.com/

你可能感兴趣的文章
MySQL8修改密码报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
查看>>
MySQL8修改密码的方法
查看>>
Mysql8在Centos上安装后忘记root密码如何重新设置
查看>>
Mysql8在Windows上离线安装时忘记root密码
查看>>
MySQL8找不到my.ini配置文件以及报sql_mode=only_full_group_by解决方案
查看>>
mysql8的安装与卸载
查看>>
MySQL8,体验不一样的安装方式!
查看>>
MySQL: Host '127.0.0.1' is not allowed to connect to this MySQL server
查看>>
Mysql: 对换(替换)两条记录的同一个字段值
查看>>
mysql:Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘解决方法
查看>>
MYSQL:基础——3N范式的表结构设计
查看>>
MYSQL:基础——触发器
查看>>
Mysql:连接报错“closing inbound before receiving peer‘s close_notify”
查看>>
mysqlbinlog报错unknown variable ‘default-character-set=utf8mb4‘
查看>>
mysqldump 参数--lock-tables浅析
查看>>
mysqldump 导出中文乱码
查看>>
mysqldump 导出数据库中每张表的前n条
查看>>
mysqldump: Got error: 1044: Access denied for user ‘xx’@’xx’ to database ‘xx’ when using LOCK TABLES
查看>>
Mysqldump参数大全(参数来源于mysql5.5.19源码)
查看>>
mysqldump备份时忽略某些表
查看>>