Primary Arithmetic
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 11135   Accepted: 4093

Description

Children are taught to add multi-digit numbers from right-to-left one digit at a time. Many find the "carry" operation - in which a 1 is carried from one digit position to be added to the next - to be a significant challenge. Your job is to count the number
of carry operations for each of a set of addition problems so that educators may assess their difficulty.

Input

Each line of input contains two unsigned integers less than 10 digits. The last line of input contains 0 0.

Output

For each line of input except the last you should compute and print the number of carry operations that would result from adding the two numbers, in the format shown below.

Sample Input

123 456
555 555
123 594
0 0

Sample Output

No carry operation.
3 carry operations.
1 carry operation.

Source

Waterloo local 2000.09.23

你  离  开  了  ,  我  的  世  界  里  只  剩  下  雨  。  。  。

#include <cstdio>
int main()
{
long int a, b;
int carry, c;
while (scanf("%ld%ld", &a, &b) , a + b)
{
carry = c = 0;
while (a || b)
{
c = (a % 10 + b % 10 + c) > 9 ? 1 : 0;
carry += c;
a /= 10;
b /= 10;
}
if (carry == 0)puts("No carry operation.");
else if (carry == 1)puts("1 carry operation.");
else printf("%d carry operations.\n", carry);
}
return 0;
}

POJ 2562:Primary Arithmetic的更多相关文章

  1. BNUOJ 1006 Primary Arithmetic

    Primary Arithmetic 来源:BNUOJ 1006http://www.bnuoj.com/v3/problem_show.php?pid=1006 当你在小学学习算数的时候,老师会教你 ...

  2. UVA OJ 10035 - Primary Arithmetic

    Primary Arithmetic Children are taught to add multi-digit numbers from right-to-left one digit at a ...

  3. 1350. Primary Arithmetic

    Children are taught to add multi-digit numbers from right-to-left one digit at a time.  Many find th ...

  4. POJ 2562

    #include<iostream> #include<algorithm> #define MAXN 15 using namespace std; //int rec[MA ...

  5. 九度OJ 1143:Primary Arithmetic(初等数学) (进位)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:616 解决:254 题目描述: Children are taught to add multi-digit numbers from ri ...

  6. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  7. Zerojudge解题经验交流

    题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识 ...

  8. (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO

    http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...

  9. ACM训练计划step 1 [非原创]

    (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...

随机推荐

  1. mysql jdbc驱动与java 版本对应关系

    当使用某些密码套件时,Connector/J5.1需要JRE 1.8.x才能使用SSL/TLS连接到MySQL 5.6,5.7和8.0.

  2. php 日常问题

    1.isset.empty.is_null的区别 isset 判断变量是否定义或者是否为空 变量存在返回ture,否则返回false 变量定义不赋值返回false unset一个变量,返回false ...

  3. YOLOv3配置(win10+opencv3.40+cuda9.1+cudnn7.1+vs2015)

    最近心血来潮想学一下YOLOv3,于是就去网上看了YOLOv3在win10下的配置教程.在配置过程中塌坑无数,花了很多时间和精力,所以我想就此写一篇博客来介绍在在win10+vs2015的环境下如何配 ...

  4. 新进Linux菜鸟,请多多关照

    早早知晓Linux的大名,一直未研究学习,近来看了kernel一些源代码,在网上搜过很多基础的知识.感觉这个Linux的世界很广大,值得好好深入学习.初生婴儿,呱呱落地,必先躺若干日后能坐,在学爬,进 ...

  5. 74-A/D指标,Accumulation/Distribution,积累/派发线,离散指标.(2015.7.1)

    A/D指标,Accumulation/Distribution 积累/派发线,离散指标 观井映天 2015.7.1

  6. Mybatis 处理日期格式自动转换

    java.lang.String和java.util.Date之间自动转换 @DateTimeFormat(pattern="yyyy-MM-dd")//页面写入数据库时格式化 @ ...

  7. 【KMP+最小循环节】F. Cyclic Nacklace

    https://www.bnuoj.com/v3/contest_show.php?cid=9147#problem/F [题意] 给定一个字符串,问在字符串后最少添加多少个字母,得到的新字符串能是前 ...

  8. 变量&字符串

    变量 变量定义规范: # 声明变量: name = "Neo Zheng" # name为变量名(标识符),"Neo Zheng"是变量值. 变量定义规则: 1 ...

  9. 【IntelliJ 】设置 IntelliJ IDEA 主题和字体的方法

    2 主题修改 2.1 界面主题修改 如上图所示,依次点击Files -> Settings,进入如下界面: 标注1:主题选择区: 标注2:Darcula.IntelliJ 和 Windows,三 ...

  10. MongoDB学习day03--索引和explain分析查询速度

    一.索引基础 db.user.ensureIndex({"username":1}) 创建索引,username为key,数字 1 表示 username 键的索引按升序存储, - ...