首页 > 试题广场 >

Integer Inquiry

[编程题]Integer Inquiry
  • 热度指数:4334 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
    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.)

输入描述:
    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.

注意输入数据中,VeryLongInteger 可能有前导0


输出描述:
    Your program should output the sum of the VeryLongIntegers given in the input.
示例1

输入

123456789012345678901234567890
123456789012345678901234567890
123456789012345678901234567890
0

输出

370370367037037036703703703670
头像 wbc990512
发表于 2021-02-09 13:42:45
简单的大数加法,按照竖式的计算方式从最低位往最高位加,记住进位即可。 #include<stdio.h> #include<string.h> int main() { char str1[101]; // 始终将str1作为中间结果 char str2[10 展开全文
头像 T790T
发表于 2024-07-30 09:29:59
#include <bits/stdc++.h> using namespace std; int res[1001] = {0}; void add(string str) { int len = str.size(); int carry = 0; int 展开全文
头像 ZukaiMobby
发表于 2023-02-03 18:23:54
#include <string.h> #include <algorithm> #include <iostream> #define MAX_DIGITS 1000 using namespace std; void add(char a[], char b 展开全文
头像 牛客440904392号
发表于 2024-09-29 22:49:45
//Java版代码 import java.util.Scanner; import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner sc = 展开全文
头像 牛客7777779号
发表于 2023-03-16 16:56:39
注意数组大小要给够,不然测试用例会失败 #include <iostream> using namespace std; int main(){ string str; int s[103] = {0}; int i,j; while (cin >>str 展开全文
头像 lyw菌
发表于 2023-03-11 15:44:45
#include "stdio.h" #include "string" #include "algorithm" using namespace std; char buf[110][110]; int n = 0;//记录输入的行数为(n-1) string addString(string 展开全文
头像 笑川不吃香菜
发表于 2024-03-23 08:37:05
import java.util.Scanner; import java.math.BigInteger; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] 展开全文
头像 chong_0428
发表于 2025-02-16 23:06:54
s = [] while True: a = int(input()) if a == 0: break s.append(a) print(sum(s))
头像 HENU彭于晏
发表于 2023-03-26 20:33:02
#include<string> #include<cstdio> #include<iostream> using namespace std; int main() { string str; string result1; string result 展开全文
头像 挂耳coffe
发表于 2025-03-18 21:26:26
#include <iostream> using namespace std; int main() { string str; int s[103] = {0}; int i, j; while (cin >> str &&am 展开全文

问题信息

难度:
32条回答 4211浏览

热门推荐

通过挑战的用户

查看代码
Integer Inquiry