-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path111.cpp
More file actions
57 lines (53 loc) · 1.18 KB
/
Copy path111.cpp
File metadata and controls
57 lines (53 loc) · 1.18 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
vector<int> findDeterminant(int x)
{
vector<int> result(4,0);
unordered_map<int,pair<int,int>> map;
for(int i = 1;i<=20;i++)
{
for(int j = 1;j<=20;j++)
{
int sum = i*j;
if(map.count(sum-x))
{
result[0] = i;
result[3] = j;
result[1] = map[sum-x].first;
result[2] = map[sum-x].second;
return result;
}
if(map.count(sum+x))
{
result[1] = i;
result[2] = j;
result[0] = map[sum+x].first;
result[3] = map[sum+x].second;
return result;
}
if(!map.count(sum))
{
pair<int,int> my_pair(i,j);
map[sum] = my_pair;
}
}
}
return {};
}
int main()
{
int x;
cin>>x;
vector<int> res(4,0);
res = findDeterminant(x);
if(res.empty())
{
cout<<"-1";
return 0;
}
cout<<res[0]<<" "<<res[1]<<endl;
cout<<res[2]<<" "<<res[3];
return 0;
}