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.

Each line of input contains two unsigned integers less than 10 digits.   The last line of input contains 0 0.  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

Output for Sample Input

No carry operation.
3 carry operations.
1 carry operation.
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
unsigned int m,n,sum,i;
//cin>>m>>n;
while(cin>>m>>n)
{
if(m==&&n==)
break;
unsigned int temp;
if(m<n)
{
temp=m;
m=n;
n=temp;
}
unsigned int m1,n1;
i=;
sum=;
while(m>)
{
m1=m%;
n1=n%;
if(m1+n1+i>=)
{
i=;
sum++;
}
else {
i=;
}
m=m/;
n=n/; }
while(n>)
{
if(n%+i>=)
{
i=;
sum++;
}
else
{
i=;
}
n=n/;
}
if(sum==)
{
cout<<"No carry operation."<<endl;
}
else if(sum==)
{
cout<<sum<<" carry operation."<<endl;
}
else if(sum>)
{
cout<<sum<<" carry operations."<<endl;
}
//cin>>m>>n;
}
return ;
}

1350. Primary Arithmetic的更多相关文章

  1. BNUOJ 1006 Primary Arithmetic

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

  2. POJ 2562:Primary Arithmetic

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

  3. UVA OJ 10035 - Primary Arithmetic

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

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

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

  5. Zerojudge解题经验交流

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

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

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

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

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

  8. HOJ题目分类

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

  9. zoj 1874 水题,输出格式大坑

    Primary Arithmetic Time Limit: 2 Seconds      Memory Limit: 65536 KB Children are taught to add mult ...

随机推荐

  1. scala - Map基础

    Map 构造Map 不可变: val map = Map("sa" -> 1, "s" -> 2)map("sa") = 3 / ...

  2. Hibernate的性能优化问题笔记

    性能优化 1.注意session.clear()的运用.尤其是不断分页循环的情况下. a)在一个大集合中进行遍历,遍历取出数据或者对象 b)java会引起内存泄漏吗?在语法上是不可能出现内存泄露的,因 ...

  3. zju(2)vivi的配置编译和固化

    1.实验目的 熟悉vivi的知识和应用并使用交叉编译平台vivi引导并烧写到目标板. 二.实验内容 1. 在Ubuntu下配置vivi并进行交叉编译: 2. 将编译好的vivi烧写到目标板上. 三.主 ...

  4. 20145337《JAVA程序设计》第一周学习总结

    # 20145337 <Java程序设计>第1周学习总结 ## 教材学习内容总结 第一章 -Java最早是Sun公司撰写Star7应用程序的程序语言 -根据应用领域不同,有Java SE. ...

  5. 本内容中发现无效字符。处理资源 'file:///C:/Users/XDJ/Desktop/1111/press.xml' 时出错。第 5 行,位置: 11 <author>ƽ

    粘贴到编译器中, 然后在复制出即可.

  6. BizTalk开发系列(三十六) Orchestration单实例执行

    BizTalk 是高效的消息处理引擎,采用多线程并发的方式来处理消息.也就是说当有消息被接收的时候就会产生一个新的消息处理实例.但有时目标系统可能并没有并发处理 的能力, 这时就需要在BizTalk中 ...

  7. C# 计时器

    一.Stopwatch 主要用于测试代码段使用了多少时间 使用方法: Stopwatch sw=new Stopwatch(); sw.Start(); ... sw.Stop(); Console. ...

  8. angularJs表单校验(超级详细!!!)

    html代码 <!DOCTYPE html> <html ng-app="angularFormCheckModule"> <head> < ...

  9. P1073 最优贸易

    #include <bits/stdc++.h> using namespace std; const int maxn = 100005; int head1[maxn], head2[ ...

  10. oslo.messaging 1.8.0 bug fix and blueprint

    1366597 由于amqp_auto_delete可配置,但是NotifierPublisher使用的是没有在配置中获取而使用的默认的False,即非auo_delete,因而在用户配置了amqp_ ...