summaryrefslogtreecommitdiff
path: root/2015/day20.cpp
blob: 2da1fa268903dd1b0ebc98b3758483bcd1668145 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void){
	const int limit=10000000; //1e7
	cerr<<"Alloc...";
	int *scores=(int*)calloc(limit+1,sizeof(int));
	cerr<<" done."<<endl;
	int elf,i,ilimit;
	for(elf=1;elf<=limit;elf++){
		ilimit=limit/elf;
		if(ilimit>50)ilimit=50;
		for(i=1;i<=ilimit;i++){
			scores[elf*i]+=elf*11;
		}
		if(scores[elf]>=36000000)break;
	}
	for(i=1;i<20;i++)cout<<scores[i]<<' '; cout<<endl;
	cout<<elf<<endl;
	free(scores);
}