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 teacher asked him to solve a simple problem with the equation a+1=b with positive integers a and b, but Kolya forgot the numbers a and b. He does, however, remember that the first (leftmost) digit of a was da, and the first (leftmost) digit of b was db.
Can you reconstruct any equation a+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.
思路:
特判9 1,其他的照着搞。
代码:
//#include <iostream>
//#include <fstream>
//#include <process.h>
//#include "ch08/ch08Func.cpp"
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int a, b;
cin >> a >> b;
if (a == b)
{
cout << a << '1' << ' ' << b << '2' << endl;
return 0;
}
if (a == 9 && b == 1)
{
cout << 9 << ' ' << 10 << endl;
return 0;
}
if (a > b || b-a > 1)
{
cout << -1 << endl;
return 0;
}
cout << a << '9' << ' ' << b << '0' << endl;
return 0;
}
Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) A. Forgetting Things的更多相关文章
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)
A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) D. Power Products
链接: https://codeforces.com/contest/1247/problem/D 题意: You are given n positive integers a1,-,an, and ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) C. p-binary
链接: https://codeforces.com/contest/1247/problem/C 题意: Vasya will fancy any number as long as it is a ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) B2. TV Subscriptions (Hard Version)
链接: https://codeforces.com/contest/1247/problem/B2 题意: The only difference between easy and hard ver ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) F. Tree Factory 构造题
F. Tree Factory Bytelandian Tree Factory produces trees for all kinds of industrial applications. Yo ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) E. Rock Is Push dp
E. Rock Is Push You are at the top left cell (1,1) of an n×m labyrinth. Your goal is to get to the b ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) B. TV Subscriptions 尺取法
B2. TV Subscriptions (Hard Version) The only difference between easy and hard versions is constraint ...
- 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 ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) D. Power Products 数学 暴力
D. Power Products You are given n positive integers a1,-,an, and an integer k≥2. Count the number of ...
随机推荐
- [转帖]从零开始入门 K8s:应用编排与管理:Job & DaemonSet
从零开始入门 K8s:应用编排与管理:Job & DaemonSet https://www.infoq.cn/article/KceOuuS7somCYbfuykRG 陈显鹭 阅读数:193 ...
- docker容器端口号、时区修改
一.修改端口号 在docker run创建并运行容器的时候,可以通过-p指定端口映射规则.但是,我们经常会遇到刚开始忘记设置端口映射或者设置错了需要修改.当docker start运行容器后并没有提 ...
- SQL入门经典(第四版)学习记录——SQL语法(二)
一.创建表 create table 表里包含什么类型的数据 表的名称是什么 主键 列的名称是什么 每一列的数据类型是什么 每一列的长度是多少 表里哪些列可以是空的 语法: create table ...
- java字节和字符的区别
字节: 1.bit=1 二进制数据0或1 2.byte=8bit 1个字节等于8位 存储空间的基本计量单位 3.一个英文字母=1byte=8bit 1个英文字母是1个字节,也就是8位 4.一个汉字 ...
- 怎样理解没有this的构造函数
如果一个构造函数内部没有this, 那可以说这个压根不是构造函数, 因为他并不能返回一个实例对象; function Person(name) { var name = name; }; var li ...
- 轻松搭建CAS 5.x系列(7)-在CAS Server使用第三方帐号做认证
概述说明 CAS除了使用自身数据库配置的帐号体系外,也可以使用第三方帐号来做认证. 比如实现如下类似的红色标注部分的登录效果: CAS自带了Facebook.GitHub.WordPress和CAS的 ...
- Go 代码风格和规范
Go 语言写起来类似于C语言,因此熟悉C语言及其派生语言(C++.C#.Objective-C 等)的人都会迅速熟悉这门语言 编码风格 标识符命名规范 在习惯上,Go语言程序员推荐使用驼峰式命名,当名 ...
- Docker多阶段构建实战(multi-stage builds)
在编写Dockerfile构建docker镜像时,常遇到以下问题: RUN命令会让镜像新增layer,导致镜像变大,虽然通过&&连接多个命令能缓解此问题,但如果命令之间用到docker ...
- 如何搭建一个基于nuxt.js的项目
介绍 nuxt.js(中文官方文档)是vue.js的一个通用型应用框架,有了之前搭建vue项目的过程之后,搭建一个nuxt项目就会十分简单. 搭建步骤 1.打开命令提示符,进入到相关文件夹下: 2.使 ...
- 用一个N点复序列的FFT同时计算两个N点实序列离散傅里叶变换
一.功能 用一个\(N\)点复序列快速傅立叶变换算法来同时计算两个\(N\)点实序列的离散傅立叶变换. 二.方法简介 假设\(x(n)\)与\(y(n)\)都是长度为\(N\)的实序列,为计算其离散傅 ...