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. 2019面向对象程序设计(Java) 第16周学习指导及要求

    2019面向对象程序设计(Java)第16周学习指导及要求 (2019.12.13-2019.12.16) 学习目标 (1) 掌握Java应用程序的打包操作: (2) 掌握线程概念: (3) 掌握线程 ...

  2. 设计模式-FlyWeight(结构型模式) 针对 需要创建大量对象的情形,被共享的状态作为内部状态,不被共享的状态作为外部状态

    以下代码来源: 设计模式精解-GoF 23种设计模式解析附C++实现源码 //Flyweight.h #pragma once #include<string> class FlyWeig ...

  3. Ubuntu Idea 快捷键 Ctrl+Alt+S 无法使用解决

    Idea 里习惯了用 Ctrl+Alt+S 打开设置界面,在 Ubuntu 下会因为快捷键冲突无法使用 系统快捷键 打开系统设置中的快捷键设置,按 Backspace 键禁用 Fcitx 如果你的输入 ...

  4. 修改本地的host文件

    在C:\Windows\System32\drivers\etc下有一个host文件, 在里面可以修改本地的域名,比如我文件里添加一行: 10.0.33.79    devsuite.easthope ...

  5. 前端笔记之React(七)redux-saga&Dva&路由

    一.redux-saga解决异步 redux-thunk 和 redux-saga 使用redux它们是必选的,二选一,它们两个都可以很好的实现一些复杂情况下redux,本质都是为了解决异步actio ...

  6. 数据库相关知识积累(sqlserver、oracle、mysql)

    数据库相关知识积累(sqlserver.oracle.mysql) 1. sqlserver :断开所有连接: (还原数据库) 1.数据库  分离 2. USE master GO ALTER DAT ...

  7. 常见跨域解决方案以及Ocelot 跨域配置

    常见跨域解决方案以及Ocelot 跨域配置 Intro 我们在使用前后端分离的模式进行开发的时候,如果前端项目和api项目不是一个域名下往往会有跨域问题.今天来介绍一下我们在Ocelot网关配置的跨域 ...

  8. IDEA maven设置配置

    IDEA Maven配置 1. 下载maven 下载地址 从官网上,下载一个压缩包,然后解压到任意的文件夹 Maven的安装必须需要jdk1.7+ 2. 环境变量设置 M2_HOME改为具体的路径,其 ...

  9. 死磕 java同步系列之AQS终篇(面试)

    问题 (1)AQS的定位? (2)AQS的重要组成部分? (3)AQS运用的设计模式? (4)AQS的总体流程? 简介 AQS的全称是AbstractQueuedSynchronizer,它的定位是为 ...

  10. C# Task ContinueWith

    static void Main(string[] args) { Task firstTask = Task.Run(() => { PrintPlus(); }); Task secondT ...