35 lines
608 B
C++
35 lines
608 B
C++
#include <algorithm>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <set>
|
|
#include <string>
|
|
|
|
std::set<int> read_input_file() {
|
|
std::ifstream file("input");
|
|
std::set<int> data;
|
|
std::string line;
|
|
|
|
while(std::getline(file, line))
|
|
data.insert(std::stoi(line));
|
|
|
|
return data;
|
|
}
|
|
|
|
int main(){
|
|
auto data = read_input_file();
|
|
int iterations = 0;
|
|
|
|
for(auto &i: data) {
|
|
int rest = 2020 - i;
|
|
for(auto &j: data) {
|
|
int second_rest = rest - j;
|
|
if (data.count(second_rest)) {
|
|
std::cout << i * j * second_rest << std::endl;
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
return 1;
|
|
}
|