Codeforces Round #296 (Div. 2)

本文介绍了一个名为PlayingwithPaper的折纸游戏问题,该问题是关于如何从一个矩形中切割出尽可能多的正方形。文章提供了详细的算法实现过程,包括使用C++语言编写的代码示例。

第一次做CF,唉,还是基础的东西做的太少,练得不够。

A.Playing with Paper

一个折纸游戏,大概意思就是从一个矩形中最多能切割出多少个大小可以不等的正方形。

已知长和宽a,b,不停地进行切割,上一次切割的宽度变成下一次的长,然后上一次切割的余数成为下一次的宽,然后继续切割直到b为0即切割的时候已经没有剩余。

#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#include <set>
using namespace std;


#define read() freopen("data.in", "r", stdin)
#define write() freopen("data.out", "w", stdout)
#define rep( i , a , b ) for ( int i = ( a ) ; i <  ( b ) ; ++ i )  
#define For( i , a , b ) for ( int i = ( a ) ; i <= ( b ) ; ++ i ) 
#define clr( a , x ) memset ( a , x , sizeof a )  
#define cpy( a , x ) memcpy ( a , x , sizeof a ) 
#define _max(a,b) ((a>b)?(a):(b))
#define _min(a,b) ((a<b)?(a):(b))
#define LL long long 
const int maxNumber=10002;


int main()
{
	//read();
	LL a,b;
	LL cnt;
	LL temp;
	while(cin>>a>>b)
	{
		cnt = temp = 0;
		while(b)
	   {
		cnt+=a/b;
		temp=a%b;
		a=b;
		b=temp;
	   }
	   cout<<cnt<<endl;
	}
    return 0;
   
}

  

转载于:https://www.cnblogs.com/acmsummer/p/4346132.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值