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的更多相关文章

  1. 读书摘要,一种新的黑客文化:programming is forgetting

    http://opentranscripts.org/transcript/programming-forgetting-new-hacker-ethic/ 这篇文章非常有意思,作者是一个计算机教师, ...

  2. 灾难性遗忘(catastrophic forgetting)

    Overcoming catastrophic forgetting in neural networks(克服神经网络中的灾难性遗忘) 原文: https://www.pnas.org/conten ...

  3. [CodeForces-1225A] Forgetting Things 【构造】

    [CodeForces-1225A] Forgetting Things [构造] 标签: 题解 codeforces题解 构造 题目描述 Time limit 2000 ms Memory limi ...

  4. 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 ...

  5. Overcoming Forgetting in Federated Learning on Non-IID Data

    郑重声明:原文参见标题,如有侵权,请联系作者,将会撤销发布! 以下是对本文关键部分的摘抄翻译,详情请参见原文. NeurIPS 2019 Workshop on Federated Learning ...

  6. 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 ...

  7. EntityFramework中的DbContext使用疑点说明

    1.DbContext怎么在Asp.mvc中使用? public class Repository { //实例化EF容器:有弊端.一个线程里可能会创建多个DbContext //DbContext ...

  8. RMAN异机恢复遭遇ORA-01547、ORA-01152、ORA-01110错误案例

    测试环境:     操作系统  :  Red Hat Enterprise Linux ES release 4 (Nahant Update 4)   VMWARE     数据库     :  O ...

  9. MIT 6.824 : Spring 2015 lab3 训练笔记

    摘要: 源代码参见我的github:https://github.com/YaoZengzeng/MIT-6.824 Lab3: Paxos-based Key/Value Service Intro ...

随机推荐

  1. promise 和 setTimeout 在任务队列的执行顺序

    setTimeout(() => { console.log() }); const a = new Promise((resolve,reject)=>{ console.log(); ...

  2. 洛谷 P5639 【CSGRound2】守序者的尊严

    洛谷 P5639 [CSGRound2]守序者的尊严 洛谷传送门 题目背景 由于Y校最近进行了对学校食堂的全面改革与对小卖部的全面整治(乱搞),导致学校小卖部卖的零食被禁售了:学校食堂的炸鸡窗口也消失 ...

  3. Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest dp

    E. The Contest A team of three programmers is going to play a contest. The contest consists of

  4. 第02组 Beta版本演示

    目录 1. 博客链接及组员信息(2分) 2. 贡献比例(3分) 3. GitHub 项目链接(1分) 4. 博客汇总(2分) 5. 燃尽图(3分) 6. 原计划.达成情况及原因分析(6分) 7. Be ...

  5. ASP.NET Core 模型验证的一个小小坑

    今天在我们的一个项目中遇到一个 asp.net core 模型验证(model validation)的小问题.当模型属性的类型是 bool ,而提交上来的该属性值是 null ,asp.net co ...

  6. ReactNative: 使用View组件创建九宫格

    一.简言 初学RN,一切皆新.View组件跟我们iOS中UIView类似,作为一个容器视图使用,它主要负责承载其他的子组件.View组件采用的是FlexBox伸缩盒子布局,通过对它的布局可以影响子组件 ...

  7. php+laravel依赖注入浅析

    laravel容器包含控制反转和依赖注入,使用起来就是,先把对象bind好,需要时可以直接使用make来取就好. 通常我们的调用如下. $config = $container->make('c ...

  8. 图像处理-裁剪具有透明背景的png

    我遇到了需要裁剪具有透明背景的png的问题,用 https://www.yasuotu.com/editor 这个压缩图网站解决了问题. 这里可以选择裁剪的宽度和高度,记得点击确定按钮. 裁剪完成后, ...

  9. 我说精通字符串,面试官竟然问我 Java 中的 String 有没有长度限制?

    String 是 Java 中很重要的一个数据类型,除了基本数据类型以外,String 是被使用的最广泛的了,但是,关于 String,其实还是有很多东西容易被忽略的. 就如本文我们要讨论的问题:Ja ...

  10. poj-3682 King Arthur's Birthday Celebration

    C - King Arthur's Birthday Celebration POJ - 3682 King Arthur is an narcissist who intends to spare ...