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 ...
随机推荐
- jsp连接mysql出现不支持认证协议的解决办法
错误提示 com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Client does not support authent ...
- python的路径问题
## 文件路径出错问题 """ 如何获取与当前文件相关的地址 """ import os # 当前文件的完整路径 print(__file_ ...
- POJ 2386 Lake Counting 题解《挑战程序设计竞赛》
地址 http://poj.org/problem?id=2386 <挑战程序设计竞赛>习题 题目描述Description Due to recent rains, water has ...
- C++ 拷贝构造函数 copy ctor & 拷贝赋值函数 copy op=
类中含有 指针类型 的成员变量时,就必须要定义 copy ctor 和 copy op= copy ctor 请见: class Rectangle { public: Rectangle(Rec ...
- 超实用的Java web面试题
Java web面试题 1.Tomcat的优化经验 答:去掉对web.xml的监视,把jsp提前编辑成Servlet. 有富余物理内存的情况,加大tomcat使用的jvm的内存 2.HTTP请求的GE ...
- matlab练习程序(螺线拟合)
这里待拟合的螺线我们选择阿基米德螺线,对数螺线类似. 螺线的笛卡尔坐标系方程为: 螺线从笛卡尔坐标转为极坐标方程为: 阿基米德螺线在极坐标系下极径r和极角theta为线性关系,方程为: 计 ...
- golang数据结构之用循环链表解决约瑟夫环问题
josephu.go package link import ( "fmt" ) type Kid struct { ID int next *Kid } func AddKid( ...
- ReactNative: ReactNative初始项目的结构
一.介绍 初学RN,一切皆新.在上篇中成功地创建并运行了一个React-Native项目,这个demo的基本结构都是系统已经创建好的,开发者在此结构下完成自己的开发即可.分别用Xcode和WebSto ...
- 《转》crontab 定时任务
命令格式 crontab [-u user] file crontab [-u user] [-e | -l | -r | -i ] 命令参数 -u user:用来设定某个用户的crontab服务,例 ...
- 从游击队到正规军(二):马蜂窝旅游网的IM客户端架构演进和实践总结
一.引言 移动互联网技术改变了旅游的世界,这个领域过去沉重的信息分销成本被大大降低.用户与服务供应商之间.用户与用户之间的沟通路径逐渐打通,沟通的场景也在不断扩展.这促使所有的移动应用开发者都要从用户 ...