Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main() {
- double x;
- int d1,d2,per;
- while (true) {
- cin >> x;
- if (x == 0) {
- break;
- }
- int n = (double) x;
- int a = sqrt(x);
- for (int i = 0; i < n; i++) {
- if (n%a+i == 0) {
- d1 = a+i;
- d2 = (int)n/d1;
- per = d1*2 + d2*2;
- }
- }
- cout << "Minimum perimeter is " << per << " with dimensions " << d1 << " x " << d2 << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement