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 最大波动 (水题)
问题描述 小明正在利用股票的波动程度来研究股票.小明拿到了一只股票每天收盘时的价格,他想知道,这只股票连续几天的最大波动值是多少,即在这几天中某天收盘价格与前一天收盘价格之差的绝对值最大是多少. 输入 ...
随机推荐
- 关于小程序http请求的问题
解决wx.request 发起的是 HTTPS 请求的问题 对于wx.request,大家可以理解为是微信小程序版的ajax,基于安全性考虑他的url地址必须是以https开头的,但对于一个开发者来说 ...
- VIN码识别对汽车行业的应用
汽车VIN码识别: 识别系统到底是什么呢?来~大家往下看,这是易泊时代科技有限公司通过多年的ocr识别技术,与汽车Vin码识别/车架号识别系统相结合,针对机动车配置参数等信息的查询及采集而推出的一款V ...
- 转:深入Java集合学习系列:HashMap的实现原理
1. HashMap概述: HashMap是基于哈希表的Map接口的非同步实现(Hashtable跟HashMap很像,唯一的区别是Hashtalbe中的方法是线程安全的,也就是同步的).此实现提供所 ...
- 201521123018 《Java程序设计》第1周学习总结
1. 本章学习总结 *Java程序的特点 *可以跨平台运行 *语言简单 *利用控制台运行java程序 *cmd调出控制台->用javac指令编译源代码->用java指令运行 2. 书面作业 ...
- Java 课程设计 "Give it up"小游戏设计(个人) 201521123077
1.团队课程设计博客链接 http://www.cnblogs.com/agts/p/7067948.html 2.个人负责模块或任务说明 个人任务:实现游戏画面的制作,游戏逻辑的编写,以及一些模块与 ...
- svn服务器配置与客户端的使用
1, Apache Subversion 官网下载地址: http://subversion.apache.org/packages.html#windows 官网下载提供的一般都是最新版本的,如果想 ...
- php调用webservice接口
项目中使用到了调用三方厂商webService接口.他的接口类似为http://haha.cn:86/BaseInfoService.svc?wsdl,在这里我注意到了"wsdl" ...
- pmap 命令详解
通过查看帮助,返回了如下信息: Usage: pmap [options] pid [pid ...] Options: -x, --extended show detai ...
- hive参数配置
CLI参数 两种修改方式: 1)启动时 hive --hiveconf hive.cli.print.current.db=true 2)修改当前用户home目录下 .hiverc文件,hive c ...
- 记XDCTF的misc之旅---base64隐写
bWFpbigpe2ludCBpLG5bXT17KCgoMSA8PDEpPDwgKDE8PDEpPDwoMTw8Cm==ICAgICAgIDEpPDwoMTw8KDE+PjEpKSkrKCgxPDwx ...