Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <numeric>
- #include <limits>
- using namespace std;
- /** 请完成下面这个函数,实现题目要求的功能 **/
- /** 当然,你也可以不按照这个模板来作答,完全按照自己的想法来 ^-^ **/
- int GetLeastSquareGirth(int l, int w) {
- int a,b;
- if(l>w){
- a=l;
- b=w;
- }else{
- a=w;
- b=l;
- }
- if(b==0){
- return 0;
- }
- if (b==1){
- return 4*a;
- }else{
- int mod=a%b;
- return 4*b*(a-mod)/b+GetLeastSquareGirth(mod,b);
- }
- }
- int main() {
- int res;
- int _l;
- cin >> _l;
- cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');
- int _w;
- cin >> _w;
- cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');
- res = GetLeastSquareGirth(_l, _w);
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement