POJ 1503
发布日期:2021-06-30 15:30:54
浏览次数:2
分类:技术文章
本文共 1691 字,大约阅读时间需要 5 分钟。
Integer Inquiry
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 36407 | Accepted: 14175 |
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
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900
Sample Output
370370367037037036703703703670
Source
#includeusing namespace std;#include #include int main(){ // freopen("1.txt","r",stdin);char a[110];int s[110]={0},la,ls=0;while(cin>>a){ la=strlen(a)-1; if(a[0]=='0'&&la==0) break; ls=0; for(int i=la;i>=0;i--) s[ls++]+=(a[i]-'0');}for(int i=109;i>=0;i--) if(s[i]!=0){ ls=i; break; } int k=0; while(k<=ls){ if(s[k]>=10){ s[k+1]+=s[k]/10; s[k]%=10; } k++; } while(s[ls+1]!=0){ ls++; if(s[ls-1]>10){ s[ls]+=s[ls-1]/10; s[ls-1]%=10; } } for(int i=ls;i>=0;i--) cout<
转载地址:https://joycez.blog.csdn.net/article/details/82807304 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月26日 18时05分00秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
MySQL 中基于 XA 实现的分布式事务-学习记录
2019-05-01
Java 并发学习记录之synchronized
2019-05-01
Java 并发学习记录之 wait/notify 机制
2019-05-01
Java 并发学习记录之线程间通信
2019-05-01
Java并发学习记录之volatile
2019-05-01
Docker + mysql主从配置
2019-05-01
Java集合学习之LinkedList
2019-05-01
Spring Security Oauth2 令牌增加额外信息
2019-05-01
Spring Security Oauth2 如何增加自定义授权模式
2019-05-01
logback + Kafka + logstash 集成
2019-05-01
在SpringBoot1.5.x下如何使RedisTokenStore集群化
2019-05-01
Spring Cloud Consul应用下线后,健康检查自动删除无效服务
2019-05-01
spring cloud consul 应用的多实例名的解决
2019-05-01
kafka设置某个topic的数据过期时间
2019-05-01
linux系统编程之信号(五):实时信号与sigqueue函数
2019-05-01
225. 用队列实现栈
2019-05-01
linux系统编程之信号(六):竞态条件与sigsuspend函数
2019-05-01
124. 二叉树中的最大路径和
2019-05-01
LeetCode 148:排序链表 【归并】
2019-05-01