hdu 1210 Eddy's 洗牌问题
2014-08-23 23:15
337 查看
题目链接:点击打开链接
模拟水题。
假设有n张牌,令half=n/2 , 若牌的位置p<=half 牌的位置会变为p*2,若大于half则变为(p-half)*2-1。
代码:
模拟水题。
假设有n张牌,令half=n/2 , 若牌的位置p<=half 牌的位置会变为p*2,若大于half则变为(p-half)*2-1。
代码:
#include <iostream> #include <cstdio> using namespace std; int solve(int n){ int cur=2; int half=n/2; int res=1; while(cur!=1){ if(cur<=half) cur*=2; else cur=(cur-half)*2-1; res++; } return res; } int main(){ int n; while(cin>>n){ cout<<solve(n*2)<<endl; } return 0; }
相关文章推荐
- HDU 1210 Eddy's 洗牌问题
- HDU 1210 Eddy's 洗牌问题
- HDU 1210 Eddy's 洗牌问题
- HDU 1210 Eddy's 洗牌问题
- HDU-1210-Eddy's 洗牌问题
- hdu 1210 Eddy's 洗牌问题
- HDU 1210 Eddy's 洗牌问题
- HDU 1210 Eddy's 洗牌问题(foj1062) || FOJ1050 Number lengths水
- hdu 1210 Eddy's 洗牌问题
- HDU1210 Eddy's 洗牌问题
- 杭电ACM1210——Eddy's 洗牌问题~~找规律。
- hdu 2110 Eddy's 洗牌问题
- hdoj 1210 Eddy's 洗牌问题
- 杭电OJ——1210 Eddy's 洗牌问题
- HDOJ 1210 Eddy's 洗牌问题
- hdoj 1210 Eddy's 洗牌问题 【模拟】
- Eddy's 洗牌问题(规律题+数论)
- Eddy's 洗牌问题
- hdu-1210-Eddy's 洗牌问题
- HDU - 1210 Eddy's 洗牌问题