POJ1503_Integer Inquiry

POJ1503-Integer Inquiry编程解题指南 POJ(北大在线作业系统,Peking University Online Judge)是一个面向大学生、编程爱好者的在线题库和评测系统,它提供了一个自由、开放、具有一定难度的编程练习平台。许多计算机科学与技术专业的学生以及从事IT行业的技术人员通过此平台来提高自己的编程能力,尤其是在算法和数据结构方面。POJ(Peking University Online Judge)是一个为编程爱好者提供在线编程练习的平台。 阅读详情

Integer Inquiry

Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 33767 Accepted: 13151

Description

One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers. 
``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see these results.'' (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky apartments on Third Street.) 

Input

The input will consist of at most 100 lines of text, each of which contains a single VeryLongInteger. Each VeryLongInteger will be 100 or fewer characters in length, and will only contain digits (no VeryLongInteger will be negative). 

The final input line will contain a single zero on a line by itself. 

Output

Your program should output the sum of the VeryLongIntegers given in the input.

Sample Input

123456789012345678901234567890
123456789012345678901234567890
123456789012345678901234567890
0

Sample Output

370370367037037036703703703670

Source


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
main()
{
	char str[150][150] = { 0 };
	int num[150][150] = { 0 };
	char new[150*150] = { 0 };
	int i = 0, j = 0, k = 0, len = 0, lenmax = 0, len_new = 0, re = 0, sum = 0;

	do
	{
		scanf("%s", str[i++]);
	} while (strcmp(str[i - 1],"0") != 0);
	for (j = 0;j<i-1;j++)
	{
		len = strlen(str[j]);
		if (len>lenmax)		lenmax = len;
		for (k = 0;k<len;k++)
			num[j][k] = str[j][len - k - 1] - '0';
	}
	for (j = 0;j<lenmax;j++)
	{
		for (k = 0;k<i;k++)
			sum += num[k][j];
		sum += re;
		new[j] = sum % 10+'0';
		re = sum / 10;
		sum = 0;
	}
	while (re != 0)
	{
		new[j] = re % 10+'0';
		j++;
		re = re / 10;
	}
	len_new = strlen(new);
	for (i= len_new-1;i>=0;i--)
		printf("%c", new[i]);
	printf("\n");
	return 0;
}


More:

#include<stdio.h>  
#include<string.h>  

int a[110];
char str[110];
void init(char s[], int a[])
{
	int i, j, b[110];
	int len = strlen(s);
	int k = 0;
	for (i = 0;i<len;i++)
		b[len - i - 1] = s[i] - '0';
	for (i = 0;i<len;i++)
	{
		a[i] = a[i] + b[i];
		if (a[i] >= 10)
		{
			a[i] = a[i] - 10;
			a[i + 1]++;
		}
	}
}
int main()
{
	int t, i, j;
	memset(a, 0, sizeof(a));
	while (scanf("%s", &str) && strcmp(str, "0") != 0)
	{
		init(str, a);
	}
	for (i = 110;i>0;i--)  
		if (a[i])
			break;
	for (j = i;j >= 0;j--)
		printf("%d", a[j]);
	printf("\n");
	return 0;
}


poj:在poj.org上做的一些算法题 poj 算法题 在poj.org上做的一些算法题 poj.org 账号:xxfeixiang 题目地址: 例如,第1001题的地址为: 立即下载

相关推荐

Docker 安装 CentOS7

本文主要介绍了docker 下安装centos7。访问 CentOS 镜像库地址:https://hub.docker.com/_/centos?tab=tags&page=1。可以通过 Sort by 查看其他版本的 CentOS 。默认是最新版本 centos:latest 。 使用以下命令来查看是否已安装了 centos7: 启动centos容器,并把docker上centos的22端口映射到本机60001端口(端口号可以自己指定) 3、进入到Centos容器 4.安装ssh服务和网络必须软件

折腾java的博客 1万+

POJ 1503 Integer Inquiry 【大数加法】

Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers.``Th...

weixin_34360651的博客 384

set_data_check专题[使用,report_timing,setup/hold检查]

set_data_check用于约束『数据-对-数据』的『建立保持』时间检查,通常被称为非时序约束 ( non-sequential constraints ), 理论上set_data_check 可以设在任意的两个data pin 上,其中一个pin 称为 constrained pin 类似于寄存器的data pin, 另一个pin 称为related pin 类似于寄存器的clock pin.

cy413026的博客 1万+

STATA:加i.year和不加i.year的区别

面板数据回归命令中,我们不能只固定个体,还得固定时间 只固定个体的命令:xtreg Y X C,fe,说明只认为个体之间有差异,历年的系数一样。 固定个体和时间的命令:xtreg Y X C i.year,fe,说明个体之间和时间之间均有差异,历年的系数也不一样。 ...

Hellolijunshy的博客 1万+

海康威视4G摄像头直连实战:不用萤石云,手把手教你用ISUP SDK搞定跨网段视频流

本文详细介绍了如何通过海康威视ISUP SDK实现4G摄像头的直连通信,提供了一套零平台费、自主可控的技术方案。文章涵盖技术选型、设备端配置、服务器端开发及高级应用场景,特别适合中小型安防项目,帮助开发者解决跨网段视频流传输难题,降低长期运营成本。

weixin_27076351的博客 472

IATF16949核心职位全解析

TM / Top MgmtMR / QMRProcess OwnerQMQAQCSQECQEPQEPETEMEIEPM / PJMFMEA ModeratorMSA CoordinatorSPC CoordinatorCM / CCB内审员CP / CPK

weixin_49938552的博客 975

Problem B: Integer Inquiry

Problem B: Integer Inquiry Time Limit: 1 Sec Memory Limit: 64 MB Submit: 1553 Solved: 368 Description One of the first users of BIT’s new supercomputer was Chip Diller. He extended his exploration o...

lemail0406的博客 365

YOLO小目标检测优化:9种实用方案,准确率直接提升15%

小目标检测是个系统工程,没有银弹,但有明确的优化路径。优先搞数据。Copy-Paste + 提升分辨率,这俩加起来成本最低、收益最大,能解决80%的小目标问题。别一上来就改模型结构。调参走在改结构前面。锚框聚类、损失加权、增强优化,这些都是零成本的,先做满了再说改模型的事。P2层是大杀器,但不要轻易用。加了P2层,TensorRT部署、后处理、速度都要跟着调,工程化工作量翻倍。数据和训练做到位还不够,再加也不迟。滑动窗口是兜底的。能从训练端解决的问题,就不要拖到推理端。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 196

poj(2431)(优先队列http://poj.org/problem?id=2431)

题目:http://poj.org/problem?id=2431 t

大神养成中..... 1750

ROCm rocr-libhsakmt分析系列1-2:多GPU跨卡VRAM访问机制分析

本文基于ROCr-Runtime的libhsakmt库源码,深入分析了多GPU系统中跨设备内存访问的实现机制。主要内容包括: 实现流程概述:通过P2P拓扑发现、统一虚拟地址空间、页表映射和硬件转发四个步骤,实现零拷贝的跨GPU内存访问。

图形/计算GPU的驱动与虚拟化技术分享园地 2510

腾讯面试——机器学习岗面试总结

先写合并两个有序数组,接着写合并n个有序的数组,假设总共m个数,讲了一个思路两两合并直到只剩下一个数组,分析一下时间复杂度(MlogN),面试官不满意,然后想了一下说了另一个思路,用n个指针开始指向各个数组的首端,用一个优先队列维护他们的最小值,每次拿出最小值的指针然后插入该指针的下一个值。感觉跟二面面试官聊得还是挺开心的,他详细地介绍了他们部门所做的业务,然后问了一下什么时候能来实现,我说只能暑假七八两个月,他觉得有点晚,这样子不利于转正,有些人都实习半年的,回去讨论一下,正式批之前给我答复。

FPGA/MATLAB学习教程/源码/项目合作开发 1234

poj 1503 Integer Inquiry

poj 1503 Integer Inquiry                    题目链接:http://poj.org/problem?id=1503 大数相加 题目大意:大数相加 题目分析:字符串处理 模拟  以下是代码:   #include #include #include using namespace std; int main() { int a[1000]={

slicer的技术交流栈 776

时序预测 | MATLAB实现NGM(1,1)多变量灰色时间序列预测

时序预测 | MATLAB实现NGM(1,1)多变量灰色时间序列预测

机器学习之心的博客,关注并私信文章链接,获取对应文章源码和数据。 1517

POJ 1503 Integer Inquiry

/**//************************************** Problem:POJ1503IntegerInquiry Time:0MS Memory:216K AcceptedTime:2009-05-1709:38:39 Tips:高精度加法 **************************************/ #in...

weixin_30732487的博客 96

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

POJ – 1503 Integer Inquiry Integer Inquiry

POJ –1503 Integer Inquiry Integer Inquiry Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 34728 Accepted: 13523 Description One of the firstusers

emoheithree的博客 409

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

POJ 1503Integer Inquiry

这道题应该是上个月就做完的,不打算发博客的,不过今天再看wuyiqi 大神挂在hust上的题目,然后又见到了这道题,我记得当时做的时候好多人在群里说样例过了,可是一直wa,不过题目确实描述不清,输入数字的时候可能会有前导0,其实当时做的时候我被坑的倒不是在这里,而是这道题的输入,和往常做的题目不一样,他不是要求输入多组数据,而是一直输入直到遇到0时结束输入,将这些数加起来。今天看自己当时写的代码,

笙箫默 1117

POJ1503-Integer Inquiry

全解题报告索引目录 -> 【北大ACM – POJ试题分类】 转载请注明出处:http://exp-blog.com ------------------------------------------------------------------------- 提示:就是多个大数相加的问题= = //Memory Time //184K 0MS ...

ζёСяêτ - 小優YoU 4229

POJ - 1503:Integer Inquiry

One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers. ``This supercom...

weixin_37992828的博客 128

POJ 1503 Integer Inquiry JAVA .

题目地址:http://poj.org/problem?id=1503 BigInteger 就好 import java.util.*; import java.math.*; import java.text.*; import java.io.*; public class Main { public static void main(String[] args) { Scan

BRCOCOLI的博客 304

POJ1503:Integer Inquiry

题目描述 http://poj.org/problem?id=1503 大整数加法 题目分析 大整数相关的运算,记住就好了 这题有些输入数据前导有0,所以还是乖乖用strcmp(str,”0”)吧 在discuss中发现了一种很简洁的写法 代码 自己写的 #include&lt;stdio.h&gt; #include&lt;string.h&gt; const in...

zhaoGavin的博客 334

POJ--1503:Integer Inquiry 大数加法

题目源地址:http://poj.org/problem?id=1503 程序源代码:

酒酿小圆子呀~ 839
上一篇: POJ3617_Best Cow Line
下一篇: CodeForces501A_Contest
ZayneHuang
博客等级 码龄10年 5粉丝 116原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值