Project Euler Homework
|
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 |
Find the first ten digits of the sum of one-hundred 50-digit numbers.
Definition in file 013.cpp.
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.
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.