-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteger_partition.cpp
More file actions
37 lines (34 loc) · 1.3 KB
/
Copy pathinteger_partition.cpp
File metadata and controls
37 lines (34 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*Author: Andrew H. Pometta
Last updated: 2/23/2018
This file is the main file for the Project Euler #207 project. It uses
the RatioKCalculator found in ratio_k_calculator.hpp and implemented in
ratio_k_calculator.cpp. The program takes in FROM THE STANDARD INPUT
(i.e. NOT from an argument file, due to the specifications in the problem)
a number on a line corresponding to a list of queries, followed by that
number of queries on each line. Each query has two integers a and b.
For details, see the readme or the problem page at:
https://www.hackerrank.com/contests/projecteuler/challenges/euler207 */
#include <iostream>
#include <cstdlib>
#include "ratio_k_calculator.hpp"
using namespace std;
int main(){
RatioKCalculator calc;
/*Since the problem doesn't test for checking input formatting and is really
clear about it, I don't do any checking for proper formatting. Don't run
the program on one that is not properly formatted, lest it run until
manually terminated. I may add checks later. */
int q;
cin >> q;
for (int i = 0; i < q; ++i){
lint a, b;
cin >> a >> b;
lint k = calc.getK(a, b);
if (k == 0){
cerr << "K acquisition failed at a = " << a << ", b = " << b << endl;
return EXIT_FAILURE;
}
cout << k << endl;
}
return EXIT_SUCCESS;
}