Project Euler Homework
Classes | Typedefs | Functions | Variables

013.cpp File Reference

Find the first ten digits of the sum of one-hundred 50-digit numbers. More...

#include <iostream>
#include <fstream>

Go to the source code of this file.

Classes

class  bigN

Typedefs

typedef unsigned long long verylong

Functions

void import (bigN **N)
int main ()

Variables

const verylong digits = 1e18
const int length = 18
const int gps = 4

Detailed Description

Find the first ten digits of the sum of one-hundred 50-digit numbers.

Definition in file 013.cpp.


Function Documentation

int main ( )

C++ types:
unsigned long: up to 2^32-1 ~ 10^9.63
unsigned long long: up to 2^64-1 ~ 10^19.27

Let x be the number in one segment,

each segments should contains at most 18 digits.

\[ 2x<2^64 \Rightarrow x<2^63 \Rightarrow x<= 10^18 \]

For a 50 digit number, there are a total of 50/18<=3 segments. Since it involves the sum of 100 numbers, 4 segments are recommended.

Sum each segments, then raise the “surplus” digits to next segments.

Definition at line 98 of file 013.cpp.

 All Classes Files Functions Variables