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) {
- if(w==0){
- return 0;
- }
- if (w==1){
- return 4*l;
- }else{
- int mod=l%w;
- return 4*w*(l-mod)/w+GetLeastSquareGirth(mod,1);
- }
- }
- 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