hdu 1002 A + B Problem II【大数加法】
题目大意:
手动模拟大数加法,从而进行两个大数的加法运算
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define MAXN 3000
int a[MAXN], b[MAXN];
int main()
{
int t;
scanf(;
getchar(); int array[MAXN];
while (t--)
{
memset(a, , sizeof(a));
memset(b, , sizeof(b));
memset(array, , sizeof(array));
], arr2[];
scanf("%s", arr1); int len1 = strlen(arr1);
, j = ; i >= ; i--, j++)
{
a[j] = arr1[i] - ';
}
scanf("%s", arr2); int len2 = strlen(arr2);
, j = ; i >= ; i--, j++)b[j] = arr2[i] - ';
int lenoo = max(len1, len2);
;
int i;
; i<lenoo; i++)
{
array[i] = ((a[i] + b[i]) + c) % ;
c = (a[i] + b[i] + c) / ;
}
if (c)
{
array[i] = array[i] + c; lenoo += ;
}
printf("Case %d:\n", ++ans);
; i >= ; i--)printf("%d", a[i]); printf(" + ");
; i >= ; i--)printf("%d", b[i]); printf(" = ");
; i >= ; i--)printf("%d", array[i]);
printf("\n");
if (t)printf("\n");
}
;
}
2018-04-09
hdu 1002 A + B Problem II【大数加法】的更多相关文章
- HDU 1002 A + B Problem II(高精度加法(C++/Java))
A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 抓起根本(二)(hdu 4554 叛逆的小明 hdu 1002 A + B Problem II,数字的转化(反转),大数的加法......)
数字的反转: 就是将数字倒着存下来而已.(*^__^*) 嘻嘻…… 大致思路:将数字一位一位取出来,存在一个数组里面,然后再将其变成数字,输出. 详见代码. while (a) //将每位数字取出来, ...
- 大数加法~HDU 1002 A + B Problem II
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1002 题意: 数学题,A+B; 思路,这个数非常大,普通加法一定会超时,所以用大数加法.大数加法的基 ...
- HDU 1002 A + B Problem II
A + B Problem II Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16104 Accepted ...
- HDU 1002 A + B Problem II(大整数相加)
A + B Problem II Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u De ...
- A + B Problem II 大数加法
题目描述: Input The first line of the input contains an integer T(1<=T<=20) which means the number ...
- HDU 1002 A + B Problem II (大数加法)
题目链接 Problem Description I have a very simple problem for you. Given two integers A and B, your job ...
- hdu 1002 A + B Problem II(大数)
题意:就是求a+b (a,b都不超过1000位) 思路:用数组存储 第一道大数的题目,虽然很水,纪念一下! 代码: #include<cstdio> #include<cstring ...
- HDU 1002 A + B Problem II( 高精度加法水 )
链接:传送门 题意:A + B 高精度,板子题 /************************************************************************* & ...
随机推荐
- D - 文理分科 HYSBZ - 3894(最小割)
题目链接:https://cn.vjudge.net/contest/281959#problem/D 题目大意:中文题目 具体思路: 首先说一下最小割:在最小代价的前提下,删除一些边之后,能够使得整 ...
- JQuery中的$.getScript()、$.getJson()和$.ajax()方法
$.getScript() 有时候,在页面初次加载时就取得所需的全部JavaScript文件是完全没有必要的.虽然可以在需要哪个JavaScript文件时,动态地创建<script>标签, ...
- 【学习博客】Python学习初体验
本周是正式开始学习Python的第一周.很久不写代码了,毕业第5年了,期间几乎没怎么动过手.这段时间比较规律.密集的学习又让我找回了当时的感觉,还不算陌生,我挺喜欢的这种能实实在在看到自己知识增长的状 ...
- 【C++】结构体、联合体大小计算
struct结构体大小计算 struct A { char a; int b; char c; } 这个结构体中,char占据1字节,int占据4字节,char占据1字节,而这组数据结构的大小是12字 ...
- Cython的简单使用
Cython是一个快速生成Python扩展模块的工具,从语法层面上来讲是Python语法和C语言语法的混血,当Python性能遇到瓶颈时,Cython直接将C的原生速度植入Python程序,这样使Py ...
- [Shell]获取IP地址
ifconfig eth0 | grep "inet addr:" | awk '{print $2}' | cut -c 6- ifconfig eth1 | grep &quo ...
- motor的使用
# -*- coding: utf-8 -*- # @Time : 2018/11/18 10:41 PM # @Author : cxa # @File : motordb.py # @Softwa ...
- Win10 + VS2017 15.5.6 环境下解决 Python 3.6 环境无法刷新DB的问题
作为宇宙第一IDE,VS2017对Python的支持还算可以,虽然和PyCharm等Python专用IDE相比还有些差距,但是经过后续的更新升级,我相信VS2017将越来越完善.由于本人一直都是使用V ...
- 10-关于DOM的事件操作
一.JavaScript的组成 JavaScript基础分为三个部分: ECMAScript:JavaScript的语法标准.包括变量.表达式.运算符.函数.if语句.for语句等. DOM:文档对象 ...
- Go语言学习之路(持续更新中)
菜鸟 Go语言教程 教程(RUNOOB.COM):http://www.runoob.com/go/go-tutorial.html Go全球官网:https://golang.org/ (2018- ...