题目链接>>>>>>

题目大意:
手动模拟大数加法,从而进行两个大数的加法运算

#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【大数加法】的更多相关文章

  1. 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) ...

  2. 抓起根本(二)(hdu 4554 叛逆的小明 hdu 1002 A + B Problem II,数字的转化(反转),大数的加法......)

    数字的反转: 就是将数字倒着存下来而已.(*^__^*) 嘻嘻…… 大致思路:将数字一位一位取出来,存在一个数组里面,然后再将其变成数字,输出. 详见代码. while (a) //将每位数字取出来, ...

  3. 大数加法~HDU 1002 A + B Problem II

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1002 题意: 数学题,A+B; 思路,这个数非常大,普通加法一定会超时,所以用大数加法.大数加法的基 ...

  4. HDU 1002 A + B Problem II

    A + B Problem II   Time Limit: 1000MS      Memory Limit: 65536K Total Submissions: 16104    Accepted ...

  5. HDU 1002 A + B Problem II(大整数相加)

    A + B Problem II Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u De ...

  6. A + B Problem II 大数加法

    题目描述: Input The first line of the input contains an integer T(1<=T<=20) which means the number ...

  7. HDU 1002 A + B Problem II (大数加法)

    题目链接 Problem Description I have a very simple problem for you. Given two integers A and B, your job ...

  8. hdu 1002 A + B Problem II(大数)

    题意:就是求a+b (a,b都不超过1000位) 思路:用数组存储 第一道大数的题目,虽然很水,纪念一下! 代码: #include<cstdio> #include<cstring ...

  9. HDU 1002 A + B Problem II( 高精度加法水 )

    链接:传送门 题意:A + B 高精度,板子题 /************************************************************************* & ...

随机推荐

  1. android 内存泄漏,以及检测方法

    1.为什么会产生内存泄漏 当一个对象已经不需要再使用本该被回收时,另外一个正在使用的对象持有它的引用从而导致它不能被回收,这导致本该被回收的对象不能被回收而停留在堆内存中,这就产生了内存泄漏. 2.内 ...

  2. 【tomcat】sessionId学习(未完待续)

    这里主要研究tomcat中session的管理方式以及sessionId的原理,下文将研究sessionid存到redis中以及基于redis实现session共享. 平时也就是了解session是基 ...

  3. ODPS

    ODPS 功能之概述篇 原文  http://blog.aliyun.com/2962 主题 SQL 概述 ODPS是阿里云基于自有的云计算技术研发一套开放数据处理服务(Open Data Proce ...

  4. ARMV8 datasheet学习笔记4:AArch64系统级体系结构之编程模型(2)- 寄存器

    1. 前言 2. 指令运行与异常处理寄存器 ARM体系结构的寄存器分为两类: (1)系统控制和状态报告寄存器 (2)指令处理寄存器,如累加.异常处理 本部分将主要介绍如上第(2)部分的寄存器,分为AA ...

  5. vim 超强发行版

    推荐第一个: https://github.com/spf13/spf13-vim https://github.com/Spacevim/Spacevim https://github.com/JB ...

  6. unbuntu 16.04.2 安装 Eclipse C++开发环境

    1.安装JAVA (1)首先添加源: sudo gedit /etc/apt/sources.list 在打开的文件中添加如下内容并保存: deb http://ppa.launchpad.net/w ...

  7. python 语言特性

    动态强类型: 动态类型语言:在运行期进行类型检查的语言,也就是在编写代码的时候可以不指定变量的数据类型,比如Python和Ruby 静态类型语言:它的数据类型是在编译期进行检查的,也就是说变量在使用前 ...

  8. 读SRE Google运维解密有感(二)

    前言 这是读“SRE Google运维解密”有感第二篇,第一篇参见 这本书最近又读了几章,结合自己的经历,有些地方真的能感同身受,有些地方也惊叹SRE充满辩证的思想,总之SRE是好一本好书,会给你很大 ...

  9. 关于php-fpm方式和apache配合使用的几点记录

    1.apache2.4以后可以编译单独的模块可以使用fastcgi和phpfpm进行配合,打开以下的模块即可 LoadModule proxy_module modules/mod_proxy.so ...

  10. 解决win 10下git bash中文乱码

    解决步骤如下: 1.在git bash窗体下右键,选择options 2.在打开的配置窗口左侧选择  Text,然后在右侧选择locale为zh_CN,Character set 为GBK,点击OK保 ...