zoj 1874 水题,输出格式大坑
Primary Arithmetic
Time Limit:
2 Seconds Memory Limit:
65536 KB
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.
题目没什么难度,唯一值得我写的就是:假如我的同桌是小明,他的作文里有10处错误。
(单复数,woc)。233333333333333333333333
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<memory.h>
#include<math.h>
using namespace std;
int a[12],b[12];
int main()
{
int x,y;
while(cin>>x>>y)
{
if(x==0&&y==0) return 0;
for(int i=1;i<12;i++) a[i]=b[i]=0;
int L1=0,L2=0,ans=0;
while(x!=0){
a[++L1]=x%10;
x/=10;
}
while(y!=0){
b[++L2]=y%10;
y/=10;
}
for(int i=1;i<=10;i++)
{
a[i]=a[i]+b[i];
if(a[i]>=10) ans++;
a[i+1]+=a[i]/10;
}
if(ans==0) printf("No carry operation.\n");
else if(ans==1) printf("1 carry operation.\n",ans);
else printf("%d carry operations.\n",ans);
}
}
zoj 1874 水题,输出格式大坑的更多相关文章
- 水题 ZOJ 3875 Lunch Time
题目传送门 /* 水题:找排序找中间的价格,若有两个,选价格大的: 写的是有点搓:) */ #include <cstdio> #include <iostream> #inc ...
- 水题 ZOJ 3876 May Day Holiday
题目传送门 /* 水题:已知1928年1月1日是星期日,若是闰年加1,总天数对7取余判断就好了: */ #include <cstdio> #include <iostream> ...
- 水题 ZOJ 3880 Demacia of the Ancients
题目传送门 /* 水题:) */ #include <cstdio> #include <iostream> #include <algorithm> #inclu ...
- ZOJ 2679 Old Bill ||ZOJ 2952 Find All M^N Please 两题水题
2679:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1679 2952:http://acm.zju.edu.cn/onli ...
- 水题 ZOJ 3869 Ace of Aces
题目传送门 水题,找出出现次数最多的数字,若多个输出Nobody //#include <bits/stdc++.h> //using namespace std; #include &l ...
- ZOJ 17届校赛 Knuth-Morris-Pratt Algorithm( 水题)
In computer science, the Knuth-Morris-Pratt string searching algorithm (or KMP algorithm) searches f ...
- ZOJ 3778 C - Talented Chef 水题
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3778 题意:有n道菜,每道菜需要\(a_i\)道工序,有m个锅可 ...
- 蓝桥杯 算法训练 Torry的困惑(基本型)(水题,筛法求素数)
算法训练 Torry的困惑(基本型) 时间限制:1.0s 内存限制:512.0MB 问题描述 Torry从小喜爱数学.一天,老师告诉他,像2.3.5.7……这样的数叫做质数.Torry突 ...
- CCF 201612-1 最大波动 (水题)
问题描述 小明正在利用股票的波动程度来研究股票.小明拿到了一只股票每天收盘时的价格,他想知道,这只股票连续几天的最大波动值是多少,即在这几天中某天收盘价格与前一天收盘价格之差的绝对值最大是多少. 输入 ...
随机推荐
- Microsoft Visual Studio 打开代码出现乱码解决方案
在用VS编写代码时,文本的字符集可能和编译器的字符集不同,在这种情况下代码会显示出乱码. 解决办法: 在VS的工具->选项里面找到"文本编辑器",勾选“自动检测不带签名的UT ...
- HTTPS静态服务搭建过程详解
HTTPS服务对于一个前端开发者来说是一个天天打招呼的老伙计了,但是之前我跟HTTPS打交道的场景一直是抓包,自己没有亲自搭建过HTTPS服务,对HTTPS的底层知识也是一知半解.最近正好遇到一个用户 ...
- 201521123084 《Java程序设计》第14周学习总结
1. 本周学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结数据库相关内容. answer: 2. 书面作业 1. MySQL数据库基本操作 1.1 建立数据库test.表studen ...
- 201521123121 《JAVA程序设计》第6周学习总结
1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图,对面向对象思想进行一个总结. 注1:关键词与内容不求多,但概念之间的联系要清晰,内容覆盖 ...
- 201521123005 《Java程序设计》 第九周学习总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. 2. 书面作业 本次PTA作业题集异常 1.常用异常 题目5-1 1.1 截图你的提交结果(出现学号) 1.2 自己 ...
- java课设-计算数学表达式的程序,201521123050,肖世松,个人
1.团队课程设计博客链接 http://www.cnblogs.com/xss666/p/7063780.html 2.个人负责模块或任务说明 个人负责:计算器外观,左容器CalPanelL p1: ...
- Java:设计类的继承关系时的技巧
继承设计的技巧: (1)将公共操作和域放置在超类 (2)不要使用受保护的域 有些程序员认为,将大多数的实例域定义为protected是一个不错的主意,只有这样,子类才能够在需要的时候直接访问他们.然而 ...
- POJ-3045 Cow Acrobats (C++ 贪心)
Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away a ...
- HDFS的web接口
50070端口查看NameNode状态,该端口的定义位于core-default.xml中,可以在core-site.xml中自行修改. 50075端口查看DataNode的,该地址和端口的定义位于h ...
- JVM菜鸟进阶高手之路一(一次与笨神,阿飞近距离接触修改JVM)
转载请注明原创出处,谢谢! 今天在JVMPocket群里面看见,阿牛发了一个gc截图,之后ak47截图了特别恐怖,我就觉得好奇,去看看服务情况,截图日志如下 关于jstat命令详情可以参考:https ...