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. JS分页方法

    /** maxpage 最大页数 */function gotoPage(maxpage){         var gotoPage = document.getElementById(" ...

  2. Linux下配置Lamp

    linux下配置lamp步骤: 一.快速安装Apache+PHP5+MySql 先更新: # yum update 然后安装LAMP环境:(163的yum源上只有php5.1.6 mysql 5.0. ...

  3. HDU2563 递推

    统计问题 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  4. c#语句 习题

    1.输入月份,日期,打印出是今年的第几天.(今年是平年) 2. 一个游戏,前20关是每一关自身的分数,21-30关每一关是10分,31-40关每一关是20分,41-49关每一关是30分,50关是100 ...

  5. 面向过程—面向对象(C++的封装,this)_内存四区_变量生命周期

    1.面向对象主要涉及  构造函数.析构函数.虚函数.继承.多态等. 2.对各种支持 的底层实现机制 c语言中,数据 和 处理数据的操作(函数) 是分开来声明,即语言本身并没有支持 “数据和函数”的关联 ...

  6. HTML中id、name、class 区别

    参考:http://www.cnblogs.com/polk6/archive////.html http://blog.csdn.net/ithomer/article/details/ HTML ...

  7. Cocos2d-x环境搭建

    资源列表 官网上下载最新的cocos2d-x-3.3. 安装JDK,Eclipse,CDT插件,ADT插件. 下载Android SDK,更新.因为国内经常访问不了google,用vpn速度也有点慢. ...

  8. 【iCore3 双核心板_FPGA】实验二十二:Niosii——固化程序到 EPCS 里

    实验指导书及代码包下载: http://pan.baidu.com/s/1c2lyNQS iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...

  9. Memcached 笔记与总结(9)Memcached 与 Session

    一.Memcached 存储 Session 由于 Memcached 是分布式的内存对象缓存系统,因此可以用来实现 Session 同步:把 Web 服务器中的内存组合起来,成为一个“内存池”,不管 ...

  10. laravel redis

    安装配置redis服务器 $ wget http://download.redis.io/releases/redis-3.0.5.tar.gz $ tar xzf redis-.tar.gz $ c ...