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通配符进行模糊查询

    在mysql数据库中,当我们需要模糊查询的时候 ,我们会使用到通配符. 首先我们来了解一下2个概念,一个是操作符,一个是通配符. 操作符 like就是SQL语句中的操作符,它的作用是指示在SQL语句后 ...

  2. win10下硬盘安装CentOS7

    安装环境: 1.系统:Windows 10 2.硬盘:SSD(已装好Win 10) + HHD(用来装CentOS 7) 准备工作: 1.DiskGenius(分区工具):用来给硬盘做分区: 2.系统 ...

  3. php 实现301重定向跳转实例代码

    本文主要介绍php 实现301重定向跳转,通过实例代码让大家更好的理解重定向的方法,有需要的小伙伴可以参考下 在php中301重定向实现方法很简单我们只要简单的利用header发送301状态代码,然后 ...

  4. python第一章计算机基础

    第一章 计算机基础 1.1 硬件 计算机基本的硬件由:CPU / 内存 / 主板 / 硬盘 / 网卡 / 显卡 / 显示器 等组成,只有硬件但硬件之间无法进行交流和通信. 1.2 操作系统 操作系统用 ...

  5. Python之函数作业

    Python之函数作业 爬页面 #爬虫页面,send一次爬一次 from urllib.request import urlopen def get(): while True: url = yiel ...

  6. *****Python之进程线程*****

    Python之进程线程 Python的threading模块   并发编程: 操作系统:位于底层硬件与应用软件之间的一层. 工作方式:向下管理硬件,向上提供接口. 进程:资源管理单位(容器) 线程:最 ...

  7. Java线上应用故障排查

    线上故障主要2种: CPU利用率很高, 内存占用率很大 一.CPU利用率很高 1. top查询那个进程CPU使用率高 2. 显示进程列表 ps -mp pid -o THREAD,tid,time 找 ...

  8. Mac os安装MySQL数据库,系统提示mysql: command not found该怎么办

    当我们安装好MySQL后,在终端输入mysql命令,发现并不能看到自己安装的数据库,这是因为你没有配置环境变量. 在os系统中安装MySQL数据库默认保存在/usr/local/mysql 那么我们应 ...

  9. 三菱PLC FB库函数调用方法 (Gx Work2版本)

    本文以 GxWorks2 软件为例 1.新建使用标签项目的工程文件 2.从其它库所在工程项目中导入库 3.选择库文件及FB功能块 4.插入FB功能块调用

  10. Node.js & Unix/Linux & NVM

    Node.js & Unix/Linux & NVM nvm https://github.com/creationix/nvm https://github.com/xyz-data ...