kburnik

C++ - Zadatak Kate i Luce

Jan 9th, 2013
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. Pripreme 2013 - C++ radionica
  4.  
  5. Zadatak: Kate i Luce
  6.  
  7. Autor zadatka: HSIN
  8.  
  9. Ponudjeno rjesenje: Kristijan Burnik, udruga informaticara Bozo Tezak
  10.  
  11. Datum rjesavanja: 2013-01-09
  12.  
  13. */
  14. #include <iostream>
  15. #include <cstdlib>
  16. #include <cmath>
  17.  
  18. using namespace std;
  19.  
  20. int main() {
  21.  
  22.     int p;
  23.    
  24.     cin >> p;
  25.  
  26.     // postoji pravilo, opseg pravokutnika je najmanji ako je kvadrat
  27.     int root = (int) sqrt(p);
  28.    
  29.     // trazimo prvi cijeli broj koji u umnosku daje povrsinu
  30.     while (p % root != 0) root --;
  31.    
  32.     // racunamo opseg po formuli
  33.     int opseg = 2 * (root + p/root);
  34.    
  35.     // ispis rezultata
  36.     cout << opseg << endl;
  37.    
  38.  
  39.     system("pause");
  40.     return 0;
  41. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×