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. VM虚拟机中CentOS6.4操作系统安装一

    在 VMware中鼠标单击“编辑虚拟机设置”,在弹出的“虚拟机设置”对话框中的“硬件”标签中选择“CD/DVD(IDE)”,然后在右侧的“CD /DVD(IDE)”连接选项中选择“使用ISO映像文件” ...

  2. [Python3网络爬虫开发实战] 1.8.4-Scrapy-Redis的安装

    Scrapy-Redis是Scrapy的分布式扩展模块,有了它,我们就可以方便地实现Scrapy分布式爬虫的搭建.本节中,我们将介绍Scrapy-Redis的安装方式. 相关链接 GitHub:htt ...

  3. laravel框架应用和composer扩展包开发

    laravel5.5+ laravel官方地址 laravel是目前最流行的php框架,发展势头迅猛,应用非常广泛,有丰富的扩展包可以应付你能想到的各种应用场景,laravel框架思想前卫,跟随时代潮 ...

  4. html页面加载初始化方法

    js: 方法一: window.onload=function(){内容} 方法二(自己定义方法): function onload(){内容} onload(); jQuery: 方法一: $(do ...

  5. nginx下TP5 隐藏入口文件+支持pathinfo模式+配置多项目根目录

    首先说下项目目录情况  跟目录/usr/share/nginx/html/(别说怎么这么深  0.0) html文件夹下面两个目录 pssh  pssh_shop 两个tp5项目分别对应两个二级域名 ...

  6. npm 发包

    前几天封装了公用的locaStorage组件,当然封装后需要发布npm官网,于是摸索了一番终于搞定了,总结下来希望对大家有所帮助 npm安装的package一般支持下面几大类: 本地包 url远程包 ...

  7. JS数组添加元素的三种方式

    1.push() 结尾添加 数组.push(元素) 参数 描述 newelement1 必需.要添加到数组的第一个元素. newelement2 可选.要添加到数组的第二个元素. newelement ...

  8. noip模拟赛 旅行

    分析:一个贪心的想法是每次找到根的点权和最大的点进行操作,关键是怎么维护.每次找最大值,修改后会对这条链上每个点的子树上的点造成影响,可以用线段树来维护.找最大值就是区间求最大值嘛,对子树进行操作利用 ...

  9. 如何将一个本来需要发几十条sql语句的需求优化成两条(非sql语句优化,而是解决方法)

    首先声明,本人所有博客均为原创,谢绝转载! 今天接到一个需求,如下 这里解释一下,为什么是几十条,因为这里面每个公式的每个条件都是一个单独的数据如净利润就是一条sql语句,而且分散在不同的表,如果此方 ...

  10. c#中的委托和事件详细学习【分6页学习】

    原文发布时间为:2008-11-01 -- 来源于本人的百度文章 [由搬家工具导入] 在本文中我首先通过一个GreetingPeople的小程序向大家介绍了委托的概念、委托用来做什么,随后又引出了事件 ...