CF1225A Forgetting Things
CF1225A Forgetting Things
题目描述
Kolya is very absent-minded. Today his math teacher asked him to solve a simple problem with the equation a + 1 = ba+1=b with positive integers aa and bb , but Kolya forgot the numbers aa and bb . He does, however, remember that the first (leftmost) digit of aa was d_ad**a , and the first (leftmost) digit of bb was d_bd**b .
Can you reconstruct any equation a + 1 = ba+1=b that satisfies this property? It may be possible that Kolya misremembers the digits, and there is no suitable equation, in which case report so.
输入格式
The only line contains two space-separated digits d_ad**a and d_bd**b ( 1 \leq d_a, d_b \leq 91≤d**a,d**b≤9 ).
输出格式
If there is no equation a + 1 = ba+1=b with positive integers aa and bb such that the first digit of aa is d_ad**a , and the first digit of bb is d_bd**b , print a single number -1−1 .
Otherwise, print any suitable aa and bb that both are positive and do not exceed 10^9109 . It is guaranteed that if a solution exists, there also exists a solution with both numbers not exceeding 10^9109 .
输入输出样例
输入 #1复制
输出 #1复制
输入 #2复制
输出 #2复制
输入 #3复制
输出 #3复制
输入 #4复制
输出 #4复制
题解:
题目翻译人赶来发布第一篇题解。
CF本场本题被hack了?
是一道分类讨论的题目。
用草纸模拟一下,我们发现题意有这么几个性质:
首先,假如\(d_b>d_a+1\),那么肯定是满足不了性质的。
然后,假如\(d_b<d_a\),也肯定满足不了性质。注意,特殊地:如果\(d_a=1,d_b=9\),那么也可以满足性质,所以这样的情况被抛弃了。
因为是SPJ。所以剩下的情况随便判一判就好了。
注意细节一定要考虑全面。
比如那组hack数据:9 9
我一开始就没考虑到,导致hack成功。
所以加了个补丁。就过了(我太菜了)
#include<cstdio>
using namespace std;
int da,db;
int main()
{
scanf("%d%d",&da,&db);
if(db>da+1 || (db<da && da!=9))
{
printf("-1");
return 0;
}
else if(da==9 && db==9)
{
printf("91 92");
return 0;
}
else if(da==9 && db!=1)
{
printf("-1");
return 0;
}
else if(da==9 && db==1)
{
printf("9 10");
return 0;
}
else if(da+1==db)
{
printf("%d %d",da,db);
return 0;
}
else
{
printf("%d %d",da*10+1,db*10+2);
return 0;
}
}
CF1225A Forgetting Things的更多相关文章
- 读书摘要,一种新的黑客文化:programming is forgetting
http://opentranscripts.org/transcript/programming-forgetting-new-hacker-ethic/ 这篇文章非常有意思,作者是一个计算机教师, ...
- 灾难性遗忘(catastrophic forgetting)
Overcoming catastrophic forgetting in neural networks(克服神经网络中的灾难性遗忘) 原文: https://www.pnas.org/conten ...
- [CodeForces-1225A] Forgetting Things 【构造】
[CodeForces-1225A] Forgetting Things [构造] 标签: 题解 codeforces题解 构造 题目描述 Time limit 2000 ms Memory limi ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) A. Forgetting Things 水题
A. Forgetting Things Kolya is very absent-minded. Today his math teacher asked him to solve a simple ...
- Overcoming Forgetting in Federated Learning on Non-IID Data
郑重声明:原文参见标题,如有侵权,请联系作者,将会撤销发布! 以下是对本文关键部分的摘抄翻译,详情请参见原文. NeurIPS 2019 Workshop on Federated Learning ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) A. Forgetting Things
链接: https://codeforces.com/contest/1247/problem/A 题意: Kolya is very absent-minded. Today his math te ...
- EntityFramework中的DbContext使用疑点说明
1.DbContext怎么在Asp.mvc中使用? public class Repository { //实例化EF容器:有弊端.一个线程里可能会创建多个DbContext //DbContext ...
- RMAN异机恢复遭遇ORA-01547、ORA-01152、ORA-01110错误案例
测试环境: 操作系统 : Red Hat Enterprise Linux ES release 4 (Nahant Update 4) VMWARE 数据库 : O ...
- MIT 6.824 : Spring 2015 lab3 训练笔记
摘要: 源代码参见我的github:https://github.com/YaoZengzeng/MIT-6.824 Lab3: Paxos-based Key/Value Service Intro ...
随机推荐
- acwing 167. 木棒
乔治拿来一组等长的木棒,将它们随机地砍断,使得每一节木棍的长度都不超过50个长度单位. 然后他又想把这些木棍恢复到为裁截前的状态,但忘记了初始时有多少木棒以及木棒的初始长度. 请你设计一个程序,帮助乔 ...
- Centos7升级gcc极简教程
centos7默认gcc版本为4.8,一般不满足编译需求,因此升级gcc版本为常见操作: 现有博客中,大多数教程都是基于源码重新编译安装:但是源码编译过程等待时间很长且编译麻烦. 因此,直接基于命令升 ...
- Noip2018Day1T3 赛道修建
题目链接 problem 给出一棵有边权的树.一条链的权值定义为该链所经过的边的边权值和.需要选出\(m\)条链,求\(m\)条链中权值最小的链的权值最大是多少. solution 首先显然二分. 然 ...
- Codeforces Round #603 (Div. 2) E. Editor 线段树
E. Editor The development of a text editor is a hard problem. You need to implement an extra module ...
- shutil模块(了解)
目录 一.shutil模块 1.1 zipfile压缩解压缩 1.2 tarfile压缩解压缩 一.shutil模块 高级的文件.文件夹.压缩包处理模块. import shutil # shutil ...
- MySQL基础之Natural Join用法
Natural join即自然连接,natural join等同于inner join或inner using,其作用是将两个表中具有相同名称的列进行匹配 用https://www.w3resourc ...
- spring的事件
理论 异步的实现方式可以使用事件,或者异步执行: spring中自带了事件的支持,核心是ApplicationEventPublisher; 事件包括三个要点: 事件的定义: 事件监听的定义: 发布事 ...
- 前端之移动端库和框架bootstrap
学习移动端场景下的js事件:制作移动端特效常用的js库:介绍移动端常用开发框架Bootstrap:介绍动态样式语言less.sass.stylus的基本使用. 移动端js事件 移动端的操作方式和PC端 ...
- java基础(10):继承、抽象类
1. 继承 1.1 继承的概念 在现实生活中,继承一般指的是子女继承父辈的财产.在程序中,继承描述的是事物之间的所属关系,通过继承可以使多种事物之间形成一种关系体系.例如公司中的研发部员工和维护部员工 ...
- Python【day 13】内置函数02
一.作用域相关-2个 1.locals() 参数是空 返回当前位置作用域的所有变量,返回的是字典 当前位置:函数内,返回局部变量 当前位置:函数外,返回全局变量 2.globals() 参数是空 返回 ...