NEC Programming Contest 2021(AtCoder Beginner Contest 229) B - Hard Calculation
题目链接:B - Hard Calculation (atcoder.jp)
Problem Statement
You are given positive integers A and B.
Let us calculate A+B (in decimal). If it does not involve a carry, print Easy
; if it does, print Hard
.
Constraints
- A and B are integers.
- 1≤A,B≤1018
Input
Input is given from Standard Input in the following format:
A B
Output
If the calculation does not involve a carry, print Easy
; if it does, print Hard
.
Sample Input 1
229 390
Sample Output 1
Hard
When calculating 229+390, we have a carry from the tens digit to the hundreds digit, so the answer is Hard
.
Sample Input 2
123456789 9876543210
Sample Output 2
Easy
We do not have a carry here; the answer is Easy
.
Note that the input may not fit into a 32-bit integer.
题意:问a+b的过程中是否产生进位,如果有输出hard,否则easy
思路:每一位都提取出来来进行运算。直到a为0或者b为0
#include<bits/stdc++.h>
using namespace std;int main(){long long a, b;cin >> a >> b;bool flag = 0;while(a && b && !flag){int ans = a % 10;int cnt = b % 10;if(ans + cnt >= 10){flag = 1;break;}a /= 10;b /= 10;}if(flag){cout << "Hard" << endl;}else{cout << "Easy" << endl;}return 0;
}
NEC Programming Contest 2021(AtCoder Beginner Contest 229) B - Hard Calculation相关推荐
- Caddi Programming Contest 2021(AtCoder Beginner Contest 193) 题解
Caddi Programming Contest 2021(AtCoder Beginner Contest 193) A - Discount 打折浮点数除即可 B - Play Snuke 枚举 ...
- NEC Programming Contest 2021 (AtCoder Beginner Contest 229)
终于开始补提了 重点 : C, E的倒着算, F的染色,G的相邻的转换: B - Hard Calculation #include <iostream> #include <alg ...
- Atcoder TOYOTA SYSTEMS Programming Contest 2021(AtCoder Beginner Contest 228) B - Takahashi‘s Secret
题目链接:B - Takahashi's Secret (atcoder.jp) Problem Statement Takahashi has N friends. They have nickna ...
- Atcoder TOYOTA SYSTEMS Programming Contest 2021(AtCoder Beginner Contest 228) C - Final Day
题目链接:C - Final Day (atcoder.jp) Problem Statement N students are taking a 4-day exam. There is a 300 ...
- KYOCERA Programming Contest 2021 (AtCoder Beginner Contest 200) A~E 题解
ABC200/KYOCERA2021 A~E [A - Century](https://atcoder.jp/contests/abc200/tasks/abc200_a) 题目大意 输入格式 输出 ...
- Mynavi Programming Contest 2021 (AtCoder Beginner Contest 201) A~E 题解
ABC201/Mynavi2021 A~E [A - Tiny Arithmetic Sequence](https://atcoder.jp/contests/abc201/tasks/abc201 ...
- TOYOTA SYSTEMS Programming Contest 2021(AtCoder Beginner Contest 228) ABCD
A 题意: 有一个开关,每天s点开,t点关(可能在第2天或第n天),判断x点时开着还是关着. 思路: 按照是否需要隔夜分个类. #include<bits/stdc++.h> using ...
- Caddi Programming Contest 2021(AtCoder Beginner Contest 193) F.Zebraness
题目链接 Problem Statement We have a grid with N horizontal rows and N vertical columns. Let (i,j) denot ...
- NOMURA Programming Contest 2021(AtCoder Regular Contest 121)
文章目录 A - 2nd Greatest Distance B - RGB Matching C - Odd Even Sort D - 1 or 2 E - Directed Tree F - L ...
最新文章
- pythonweb服务器部署iis_Python开发入门与实战15-IIS部署
- 一文搞懂select语句在MySQL中的执行流程!
- linux终端的背景_如何在终端显示图像缩略图 | Linux 中国
- void类型及void指针
- 跨业自学党的第一次面试
- matlab矩阵中的 *、/、\、.*
- bitnami_redmine3.3.0-1 问题及备份恢复
- 主键重复和唯一索引冲突_深入了解数据库索引
- HTML5期末大作业:家乡网站设计——石家庄(10页) HTML+CSS+JavaScrip 旅游网页html 家乡介绍html网页设计 dw旅游景点网页设计 web课程设计网页规划与设计
- gitlab自定义头像设置
- Linux下ALSA驱动分析
- excel 两列数据合并去重取并集
- —— GPS测量原理及应用复习-6 ——
- Qt程序运行时出现:0xc000007b错误参考解决方法
- git如何拉去开发的 最新代码_git拉取代码到本地
- LM317的直流可调稳压电源Multisim仿真设计(附仿真+论文+参考资料)
- MTK6735/37 插入USB开机
- java都市男人心痒痒_男人最想听的情话不是我爱你那是什么 说的男人心痒痒的情话大全...
- 人工智能基础之美女和野人过河问题
- python处理表格数据教程_利用Python处理Excel数据