Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <numeric>
  4. #include <limits>
  5.  
  6. using namespace std;
  7.  
  8. /** 请完成下面这个函数,实现题目要求的功能 **/
  9. /** 当然,你也可以不按照这个模板来作答,完全按照自己的想法来 ^-^ **/
  10. int GetLeastSquareGirth(int l, int w) {
  11. if(w==0){
  12. return 0;
  13. }
  14. if (w==1){
  15. return 4*l;
  16. }else{
  17. int mod=l%w;
  18. return 4*w*(l-mod)/w+GetLeastSquareGirth(mod,1);
  19. }
  20.  
  21.  
  22. }
  23.  
  24. int main() {
  25. int res;
  26.  
  27. int _l;
  28. cin >> _l;
  29. cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');
  30.  
  31.  
  32. int _w;
  33. cin >> _w;
  34. cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');
  35.  
  36.  
  37.  
  38. res = GetLeastSquareGirth(_l, _w);
  39. cout << res << endl;
  40.  
  41. return 0;
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement