NEFU 983 vd折纸
来源:互联网 发布:修图软件app 编辑:程序博客网 时间:2024/05/17 03:17
vd折纸
Num : 5
Time Limit : 1000ms
Memory Limit : 65536K
description
vd折纸VD上高数闲着无聊想要折纸,VD现在想要正方形的纸,但手中只有一张a*b的纸。于是现在需要裁纸。方法如下:先大致折出一条对角线,然后裁去多余的部分。为了节约,多出来的部分他又会做相同的步骤裁出更多的小正方形。现在VD想要知道,总共能裁出多少个小正方形。
input
多组输入输出,第一行由两个整数a,b组成(1<=b<a<=10^12)。
output
对于每组数据输出一行,VD能裁出多少个正方形。
sample_input
2 110 71000000000000 1
sample_output
261000000000000
hint
source
数据大时减法太慢,用除法处理。
AC 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&&a!=0&&b!=0) { if(a>b) { ans+=a/b; //除法,取模,减少运算次数 a=a%b; } else { ans+=b/a; b=b%a; } } cout<<ans<<endl; } return 0;}
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;}elseb=b-a;ans++;}if(a!=b)if(a>b)ans+=a/b;elseans+=b/a;cout<<ans<<endl;}return 0;}
0 0
- NEFU 983 vd折纸
- NEFU 982 vd数蚂蚁
- 折纸
- 折纸
- 折纸
- 折纸
- vd功耗
- 正方体折纸
- 折纸效果
- 折纸游戏
- 折纸问题
- 折纸问题
- 折纸长度
- 折纸问题
- 折纸问题
- 折纸问题 。。。
- 折纸问题
- 折纸练习
- 海量数据处理-思路
- c++ string 类小结(增加c++11标准)
- Linux软件包管理(YUM、RPM、源代码包、脚本安装)
- iOS-64位支持
- 对JSON格式数据的操作和解析和创建
- NEFU 983 vd折纸
- 第五周项目1-体验常成员函数
- android:layout_weight详解
- 拓扑排序
- PersonDao实现SQLiteOpenHelper的SQL功能图解
- Linux用户管理 详细介绍
- 2015年校赛总结
- 机器学习C6笔记:正则化文本回归(交叉验证,正则化,lasso)
- 修改 Ubuntu 下 Mysql 编码