vd折纸 | |||
| |||
description | |||
vd折纸 VD上高数闲着无聊想要折纸,VD现在想要正方形的纸,但手中只有一张a*b的纸。 于是现在需要裁纸。方法如下: 先大致折出一条对角线,然后裁去多余的部分。 为了节约,多出来的部分他又会做相同的步骤裁出更多的小正方形。现在VD想要知道,总共能裁出多少个小正方形。 | |||
input | |||
| |||
output | |||
| |||
sample_input | |||
| |||
sample_output | |||
| |||
hint | |||
| |||
source
数据大时减法太慢,用除法处理。
AC code:
T E L code:
| |||
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
long long a,b;
while(cin>>a>>b)
{
long long ans=0;
while(a%b!=0)
{
if(a>b)
{
a=a-b;
}
else
b=b-a;
ans++;
}
if(a!=b)
if(a>b)
ans+=a/b;
else
ans+=b/a;
cout<<ans<<endl;
}
return 0;
}
|
NEFU 983 vd折纸
最新推荐文章于 2021-01-10 23:14:23 发布