该题较为简单,模拟切割的过程即可
1.循环
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <iomanip>
#include<cmath>
#include<cstring>
#include<cctype>
#include<queue>
using namespace std;
int main()
{
int length, width,cn=0;
cin >> length >> width;
while (length!=width)
{
if (length > width)
{
length -= width;
cn++;
}
else if (length < width)
{
width -= length;
cn++;
}
}
cout << cn + 1 << endl;//最后那一下切割会多一块记得加上
return 0;
}
2.递归
#include <bits/stdc++.h>
using namespace std;
int qie(int a,int b)
{
if(a==b){
return 1;
}
return 1+qie(max(a-b,b),min(a-b,b));
}
int main()
{
cout<<qie(2019,324);
return 0;
}