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 最大波动 (水题)
问题描述 小明正在利用股票的波动程度来研究股票.小明拿到了一只股票每天收盘时的价格,他想知道,这只股票连续几天的最大波动值是多少,即在这几天中某天收盘价格与前一天收盘价格之差的绝对值最大是多少. 输入 ...
随机推荐
- kill -3 导出 thread dump
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt361 有些Java应用服务器是在控制台上运行,如Weblogic,为了方便获 ...
- grunt之clean、copy
心情不太好,正好这部分比较简单,记个流水账. ----------流水很清楚惜花这个责任,真的身份不过送运---------- clean.copy算是很重要也很简单的基本组件了. clean(V0. ...
- 转:深入Java集合学习系列:HashSet的实现原理
0.参考文献 深入Java集合学习系列:HashSet的实现原理 1.HashSet概述: HashSet实现Set接口,由哈希表(实际上是一个HashMap实例)支持.它不保证set 的迭代顺序:特 ...
- Beta版本测试报告以及Beta版本发布说明
Beta版本测试报告 请根据团队项目中软件的需求文档.功能说明.系统设计和Beta阶段的计划安排,写出软件的测试过程和测试结果,并回答下述问题. 在测试过程中总共发现了多少bug?每个类别的bug分别 ...
- Swing-JList用法-入门
注:本文所有素材均来源于How to Use Lists,本文为该文章的学习笔记. JList是Swing中的列表控件,形状如下所示: 实际上,JList有3种不同的样式: 分别为HORIZONTAL ...
- del命令实现全盘删除指定文件
@echo off Rem :全盘删除指定文件 set "fileName=Normal.dotm" set "outPutPath=C:\result.txt" ...
- VBScript中InStr函数的用法
InStr([start, ]str1, str2[, compare]) [用途]:返回str2在str1中的位置.匹配成功时,返回值最小值为1,未匹配到时返回0. [参数说明]: start:在s ...
- Java课程设计-定时器(团队)
一.团队介绍(没头脑和不高兴) 陈文俊[组长] 201521123047 网络1512 宣委 郑子熙 201521123045 网络1512 二.项目Git链接 定时器 三.项目git提交记录截图 四 ...
- java课程设计-表达式运算(团队博客)
1 团队课程设计博客 1 团队名称.团队成员介绍 团队名称 奔跑吧土拨鼠 团队成员 洪亚文 201521123065 网络1513 郑晓丽 201521123066 网络1513 2 项目git地址 ...
- 【干货】教你如何利用fullPage.js以及move.js插件打造高端大气的网站效果!
前言: 如今我们经常能见到全屏网站,尤其是国外网站.这些网站用几幅很大的图片或色块做背景,再添加一些简单的内容,显得格外的高端大气上档次. 在学习过jQuery插件之后,才发现之前的很多网站特效完全可 ...