Foj 2147 A-B Game
来源:互联网 发布:软件开发人员外派 编辑:程序博客网 时间:2024/05/22 01:45
题意:给出两个数A,B(A>B),每次操作A-(A%x),x任选,问至少需要几次操作能够使得A<B。
解法:简单贪心。每次x都取A/2+1。
代码:
#include <iostream>#include <stdio.h>using namespace std;int main(){ int t;long long A,B;int an=1; cin>>t;while(t--) { cin>>A>>B; int ans=0; while(A>B) { A-=A%(A/2+1); ans++; } printf("Case %d: %d\n",an,ans);an++; } return 0;}
0 0
- Foj 2147 A-B Game
- FZU 2147 A-B Game
- FZU 2147 A-B Game
- Problem 2147 A-B Game
- FZU-2147 A-B Game
- FZU 2147A-B Game
- FZU 2147 A-B Game
- FOJ 1759 Super A^B mod C
- FZU-Problem 2147 A-B Game
- 【瞎搞】 FZU 2147 A-B Game
- FZU - 2147 A-B Game(找规律)
- A-B Game
- A-B Game
- A-B Game
- A-B Game
- A-B Game --贪心
- FOJ 1752 && FOJ 1759 (a^b%c 的不同情况)
- FOJ 1000 PKU 1000 FJNU 1000 A+B Problem
- C#利用NOPI处理Excel的代码
- POJ 3624
- [Android]Android四大基本组件介绍与生命周期
- Hosts文件
- Section 1.1 Friday the Thirteenth
- Foj 2147 A-B Game
- 正则表达式学习整理
- 利用对象流模仿登陆注册功能——Java对象流应用
- Rhino使JavaScript应用程序更灵动
- linux修改主机名
- 对于编程:要么热爱,要么离开
- codeforces Second-Price Auction
- 随机模拟的基本思想和常用采样方法(sampling)
- hdu 2686 Matrix 最大费用最大流