A. Ehab and another construction problem

Water.

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 int x;
 5 
 6 int main()
 7 {
 8     while (scanf("%d", &x) != EOF)
 9     {
10         int a = -1, b = -1;
11         for (int i = 1; i <= x && a == -1 && b == -1; ++i)
12         {
13             for (int j = i; j <= x; ++j)
14             {
15                 if (j % i == 0 && i * j > x && j / i < x)
16                 {
17                     a = j, b = i;
18                     break;
19                 }
20             }    
21         }
22         if (a == -1) puts("-1");
23         else printf("%d %d\n", a, b);
24     }
25     return 0;
26 }
View Code

相关文章: