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. 【转】关闭firefox火狐浏览器下载完成时自动扫描(49.0.2以后版本)

    用firefox火狐浏览器下载文件到最后时,会显示"剩余时间未知",将持续10秒钟左右,即使几KB 的文件,也要持续这么长时间,问度娘才知道是自动扫描,检查是否有毒,用的却是Goo ...

  2. ZEN、ELECTRA、ALBERT

    一.ZEN 目前,大多数中文预训练模型基本上沿用了英文模型的做法,聚焦于小颗粒度文本单元(字)的输入.然而,与英文相比,中文没有空格等明确的词语边界.这个特点使得很多文本表达中存在的交叉歧义也被带入了 ...

  3. css 修改placeholder字体颜色字体大小 修改input记住账号密码后的默认背景色

     壹 ❀ 引 本来这个阶段的项目页面都是给实习生妹子做的,我只用写写功能接接数据,但这两天妹子要忙翻译,这个工作阶段也快结束了导致有点慌,只能自己把剩余的几个小页面给写了. 那么做页面的过程中,UI也 ...

  4. 实例调用(__call__())

    任何类,只需要定义一个__call__()方法,就可直接对实例进行调用 对实例进行直接调用就好比对一个函数进行调用一样 __call__()还可定义参数,所以调用完全可以把对象看成函数,把函数看成对象 ...

  5. 如何使用re模块进行测试用例的参数化

    import re import os from scripts.handle_mysql import HandleMysql from scripts.handle_config import H ...

  6. flex——justify-content属性引起的一个样式问题

     前言  在flex布局出现以前,我一般习惯使用浮动布局(float)来实现下列布局   现在尽量少用浮动布局,虽然好用,但有时会带来一些意想不到的问题,甚至导致布局错位,   一开始浮动布局只是为了 ...

  7. 黄聪:php一句代码让http跳转https

    //其他框架请加到入口某共公加载的文件中 //方法一 https状态 if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off'){ Head ...

  8. Java8新特性——集合底层源码实现的改变

    ArrayList 源码分析: jdk7: ArrayList list = new ArrayList();//初始化一个长度为10的Object[] elementData sysout(list ...

  9. [IDA]修改变量类型、删除变量名

    1. 双击变量 2. 按D转换类型(Word.Byte.Dword) 3. 按U删除变量名 4. 按N修改变量名

  10. 近日LeetCode算法(记录)

    近日LeetCode算法 前言:最近刷了好多leetcode算法题,大家知道,程序=数据结构+算法,由此可见,算法真的是很重要的呢.闲话少谈,切入正题,来看看小编觉得有点意思的5题算法题吧... 1. ...