Primary Arithmetic

来源:BNUOJ 1006
http://www.bnuoj.com/v3/problem_show.php?pid=1006

当你在小学学习算数的时候,老师会教你把两个数由右至左按位加起来。
很多时候,加法过程中会出现进位。对于一部分孩子,理解这个“进位”
在当时是很困难的事情。现在你的工作就是编写一个程序来判断两个数
相加的过程中会产生多少次进位,用以确定这两个数相加的“难度”。
Input
每一行有两个无符号整数(最大不超过1000000000),当输入0 0的时候,程序结束。
Output
对于每一行的输入两个整数,你需要判断会产生有多少个进位,每一个输出占一行。
Sample Input Sample Output
No carry operation.
carry operations.
carry operation. Source
第七届北京师范大学程序设计竞赛热身赛第一场 ()注意输出结果里面的细微区别:
operations和operation
()这个题目大多数人可能会想:直接把两个数当字符串输入再从后往前扫描处理。
其实这个题可以重复下面的过程:取余数直接得到最低位,然后消掉最低位。

题目描述

 #include<stdio.h>
int main()
{
int a,b,x,y,c;
int result;
freopen("input.txt","r",stdin);
while(scanf("%d%d",&a,&b)!=EOF)
{
if(a==&&b==) break;
result=;
c=;
while(a>||b>)
{
x=a%;
y=b%;
a=a/;
b=b/;
c=x+y+c;
if(c>=)
{
result++;
c=c/;
}
else
{
c=;
}
}
if(result==) printf("No carry operation.\n");
else
{
if(result>) printf("%d carry operations.\n",result);
else printf("%d carry operation.\n",result);
}
}
return ;
}

BNUOJ 1006 Primary Arithmetic的更多相关文章

  1. POJ 2562:Primary Arithmetic

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

  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. 九度OJ 1143:Primary Arithmetic(初等数学) (进位)

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

  5. HOJ题目分类

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

  6. Zerojudge解题经验交流

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

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

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

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

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

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

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

随机推荐

  1. UVA1476 三分法

    单峰函数(即先递增后递减,有极大值的函数),都可以用三分法来求 #include <iostream> #include <cmath> #include <cstdio ...

  2. win7 64位搭建scrapy

    http://blog.csdn.net/it_yuan/article/details/23856713 win7 64位系统依赖的scrapy文件链接:http://pan.baidu.com/s ...

  3. 2016年11月3日JS脚本简介数据类型: 1.整型:int 2.小数类型: float(单精度) double(双精度) decimal () 3.字符类型: chr 4.字符串类型:sting 5.日期时间:datetime 6.布尔型数据:bool 7.对象类型:object 8.二进制:binary 语言类型: 1.强类型语言:c++ c c# java 2.弱类型语

    数据类型: 1.整型:int 2.小数类型: float(单精度) double(双精度) decimal () 3.字符类型: chr 4.字符串类型:sting 5.日期时间:datetime 6 ...

  4. BS模式的模型结构详解

    编号:1004时间:2016年4月12日16:59:17功能:BS模式的模型结构详解 URL:http://blog.csdn.net/icerock2000/article/details/4000 ...

  5. 【Repost】A Practical Intro to Data Science

    Are you a interested in taking a course with us? Learn about our programs or contact us at hello@zip ...

  6. What are the 10 algorithms one must know in order to solve most algorithm challenges/puzzles?

    QUESTION : What are the 10 algorithms one must know in order to solve most algorithm challenges/puzz ...

  7. eclipse中文乱码

    问题描述: 在导入log4j.properties文件时里面出现中文乱码,如下: ### 设置### log4j.rootLogger = debug,stdout,D,E ### è¾“å‡ ...

  8. java正则表达式 非捕获组详解

    这几天看了下正则表达式,对非捕获组(non-capturing)进行下总结.主要总结 1个 + 2组  一共5个.(?:X) (?=X) (?<=X) (?!X) (?<!X) 一.先从( ...

  9. UpdatePanel与$.function()同时使用问题

    在.NET中使用了UpdatePanel,里面的输入框使用了jQuery的日历选择器,接下来介绍下两者同时使用的一些细节及问题的解决方法,感兴趣的各位可以参考下哈 今天,在.NET中使用了Update ...

  10. eclipse template里面的${user}更改

    打开eclipse目录下的eclipse.ini文件,添加上一行 -Duser.name="whateveryouwant" 这样在eclipse中的${user}变量的值就变成了 ...