博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #705 (Div. 2)
阅读量:3969 次
发布时间:2019-05-24

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

#include
#include
#include
#include
#include
#include
#include
using namespace std;typedef long long ll;int a[1100];int main(){ int t; cin>>t; int n,k,sum=0; while(t--){ cin>>n>>k; sum=0; memset(a,0,sizeof(a)); for(int i=n;i>=1;i--){ if((i>k||(i>=(k+1)/2))&&i!=k){ a[i]=1; sum++; } } cout<
<

题意:在星球 Lapituletti 上定义一天有h个小时,每小时m分钟。现在给一个时间,如果他在镜像中也是有效的的就输出这个时间,如果他在镜像中不是有效的,找出未来最接近它的一个时间。(如果时间由0、1、2、5、8中几个数字构成,且镜像中小时<h和分钟<m,则有效)
题解:模拟,先判断是不是是由0、1、2、5、8中的几个数字构成,在判断是不是在规定范围内,如果合法输出,不合法再在给出的时间的基础上依次增大寻找
代码:

#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;typedef long long ll;int a[1100];bool check(string s){ for(int i=0;i
>t; int h,m; string s1,s2; while(t--){ int flag=0; int ah=0,am=0; int fh=0,fm=0; cin>>h>>m; cin>>s1; if(check(s1)){ s2=change(s1); ah=(s2[4]-'0')*10+(s2[3]-'0'); am=(s2[1]-'0')*10+(s2[0]-'0'); flag=1; } string s,ts; fh=(s1[0]-'0')*10+(s1[1]-'0'); fm=(s1[3]-'0')*10+(s1[4]-'0'); if(flag&&ah
=10){ s="0"+to_string(i)+":"+to_string(j); }else if(i>=10&&j<10){ s=to_string(i)+":0"+to_string(j); }else if(i<10&&j<10){ s="0"+to_string(i)+":0"+to_string(j); }else{ s=to_string(i)+":"+to_string(j); } if(check(s)){ ts=change(s); ah=(ts[4]-'0')*10+(ts[3]-'0'); am=(ts[1]-'0')*10+(ts[0]-'0'); if(ah

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

你可能感兴趣的文章
P9-c++对象和类-02构造函数和析构函数总结
查看>>
P10-c++对象和类-03this指针详细介绍,详细的例子演示
查看>>
ksh 命令分隔符
查看>>
sed 精萃
查看>>
awk 精萃
查看>>
awk 注释
查看>>
GROUPING SETS、ROLLUP、CUBE
查看>>
数据类型和变量
查看>>
表连接(JOIN)
查看>>
游标(Cursor)
查看>>
复合语句(compound statement)
查看>>
DB2 物化查询表
查看>>
IF 语句
查看>>
循环语句
查看>>
DB2 临时表
查看>>
ITERATE、LEAVE、GOTO和RETURN
查看>>
异常处理
查看>>
存储过程
查看>>
动态SQL(Dynamic SQL)
查看>>
在存储过程之间传递数据
查看>>