Untitled

 avatar
unknown
c_cpp
6 months ago
440 B
3
Indexable
#include <iostream>
#include <string>
using namespace std;


int main() {
    int n, a, b, dist, old_dist = 100;
    cin >> n;

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            dist = abs(i - j);
            if (i * j == n && dist < old_dist) {
                a = i;
                b = j;
                old_dist = dist;
            }
        }
    }

    cout << a << " " << b << endl;
    return 0;
}
Editor is loading...
Leave a Comment