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. 使用dbms_crypto包加密关键列数据

    对于业务系统中常见的需要加密的列我们可以在应用层来实现,也可以在数据库层实现,自己验证了一下使用dbms_crypto包来封装函数实现关键列的加密. 1.数据库版本 SQL> select * ...

  2. 讨论一下hibernate如何动态注册一个动态生成的实体类

    如何动态生成实体类请参考这篇博文:http://www.cnblogs.com/anai/p/4269858.html 下面说说得到实体类后,如何能使用hibernate的接口来进行数据访问. 我们都 ...

  3. Servlet获取URL地址

    这里来说说用Servlet获取URL地址.在HttpServletRequest类里,有以下六个取URL的函数: getContextPath 取得项目名 getServletPath 取得Servl ...

  4. mysql5.5手册读书日记(4)

    <?php /* InnoDB事务模型和锁定 15.2.10.1. InnoDB锁定模式 15.2.10.2. InnoDB和AUTOCOMMIT 15.2.10.3. InnoDB和TRANS ...

  5. JNDI数据源局部配置(解决Cannot create JDBC driver of class '' for connect URL 'null')

    最开始,我是借鉴 孤傲苍狼的JNDI教程去做的,他讲得很详细,但是坏处也就是因为他讲的太详细.查了很多书,都是建议说不要用全局去配置JNDI,一是要修改tomcat的server.xml,容易破坏to ...

  6. soap request by afnetworking2.X/3.X

    for 2.X 参考 http://jiapumin.iteye.com/blog/2109378 AFHTTPRequestOperationManager *manager = [AFHTTPRe ...

  7. Docker三剑客之Swarm介绍

    DockOne技术分享(二十): 我用swarm在多台物理机调度管理容器,用ovs实现跨主机的容器互联问题 [编者的话]Swarm项目是Docker公司发布三剑客中的一员,用来提供容器集群服务,目的是 ...

  8. mvc路由注意事项

    路由表中你增加的路由顺序是很重要的.我们自定义路由是增加在默认路由之前的. 假如你搞反了,那默认路由将永远替代调用自定义路由.

  9. An AVPlayerItem cannot be associated with more than one instance of AVPlayer错误

    An AVPlayerItem cannot be associated with more than one instance of AVPlayer An AVPlayerItem cannot ...

  10. SQL基础巩固1

    直接开门见山------F4 1.查询 对指定的数据表或是视图进行检索查询,找出符合查询条件功能,具体包括以下SQL语法如下所示,其中[]为可选项 Select<列名> From<表 ...