HDU 4814 Golden Radio Base 小模拟
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4814
题意:黄金比例切割点是,如今要求把一个10进制的的数转化成一个phi进制的数,而且不能出现‘11’的情况。
思路:因为题目中给出了两个式子,题目就变成了一道简单的模拟题了。因为整个phi进制的数最多仅仅有200,而数据中最多仅仅有100位,所以从aa[50]=tot
開始模拟就可以。
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<ctype.h>
#include<algorithm>
#include<string>
#include <cstdlib>
#define PI acos(-1.0)
#define maxn 10005
#define INF 0x7fffffff
using namespace std;
int main()
{
int aa[105];
int tot;
while(~scanf("%d",&tot))
{
memset(aa,0,sizeof(aa));
aa[50]=tot;
while(1)
{
bool flag = 0 ;
for(int i=0; i<=100; i++)
{
if(aa[i]>1)
{
flag = 1;
aa[i+1]+=(aa[i]/2);
aa[i-2]+=(aa[i]/2);
aa[i]%=2;
}
}
for(int i=0;i<=100;i++)
{
if(aa[i]>0&&aa[i+1]>0)
{
flag = 1;
int t=min(aa[i],aa[i+1]);
aa[i+2]+=t;
aa[i+1]-=t;
aa[i]-=t;
}
}
if(flag==0)
break;
}
int head,tail;
for(int i=100;; i--)
{
if(aa[i]==1)
{
head=i;
break;
}
}
for(int i=0;; i++)
{
if(aa[i]==1)
{
tail=i;
break;
}
}
for(int i=head; i>=tail; i--)
{
if(i==49)
printf(".");
printf("%d",aa[i]);
}
printf("\n");
}
return 0;
}
HDU 4814 Golden Radio Base 小模拟的更多相关文章
- HDU 4814 Golden Radio Base 模拟
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4814 题目大意: 把一个正整数表示为φ进制, φ = (1+√5)/2 . 且已知: 1. φ + 1 ...
- hdu 4814 Golden Radio Base
详解见:http://blog.csdn.net/tri_integral/article/details/18666797 #include<cstdio> #include<cs ...
- HDU 4818 Golden Radio Base (2013长春现场赛B题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4814 进制转换. 现场根据题目给的两个公式,不断更新!!! 胡搞就可以了. 现场3A,我艹,一次循环开 ...
- ACM学习历程——HDU4814 Golden Radio Base(数学递推) (12年成都区域赛)
Description Golden ratio base (GRB) is a non-integer positional numeral system that uses the golden ...
- 【10.6校内测试】【小模拟】【hash+线段树维护覆盖序列】
一开始看到题就果断跳到T2了!!没想到T2才是个大坑,浪费了两个小时QAQ!! 就是一道小模拟,它怎么说就怎么走就好了! 为什么要用这么多感叹号!!因为统计答案要边走边统计!!如果每个数据都扫一遍20 ...
- hdu 3709 数字dp(小思)
http://acm.hdu.edu.cn/showproblem.php?pid=3709 Problem Description A balanced number is a non-negati ...
- 【11.8校内测试】【倒计时2天】【状压DP】【随机化?/暴力小模拟】
Solution 数据范围疯狂暗示状压,可是一开始发现状态特别难受. 将每一层的奇偶性状压,预处理所有状态的奇偶性.每一层的输入代表的其实可以是下一层某个点可以被从这一层哪些点转移到. 所以枚举每个状 ...
- hdu 4523 威威猫系列故事——过生日 小模拟
威威猫系列故事——过生日 Time Limit: 500/200 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total ...
- HDU 5102 The K-th Distance(模拟)
题意:输入一棵树,输出前k小的点对最短距离dis(i,j)的和. 模拟,官方题解说得很清楚了.不重复了. http://bestcoder.hdu.edu.cn/ 需要注意的是,复杂度要O(n+k), ...
随机推荐
- 可以放在html代码中的自动跳转代码
可以放在html代码中的自动跳转代码 有3种方法可以实现html的页面跳转,1,refresh 2,onload事件中加入代码 3,js实现 1.<html><body> ...
- /export/App/zz/phantomjs-1.9.7-linux-x86_64/bin
/export/App/zz/phantomjs-1.9.7-linux-x86_64/bin
- iOS --- [持续更新中] iOS移动开发中的优质资源
在我们做iOS APP的开发过程中, 须要非常多设计, 产品, 技术, 运营等方面的技巧和资源. 现将其整理汇总, 本文会一直持续更新. 敬请关注. 设计 Dribbble Dribbble是一个面向 ...
- BZOJ 1617: [Usaco2008 Mar]River Crossing渡河问题( dp )
dp[ i ] = max( dp[ j ] + sum( M_1 ~ M_( i - j ) ) + M , sum( M_1 ~ M_i ) ) ( 1 <= j < i ) 表示运 ...
- PHP学习笔记9-生成图片
用PHP代码在网页上生成图片 <?php /** * Created by PhpStorm. * User: Administrator * Date: 2015/6/29 * Time: 2 ...
- r语言之给定的概率密度函数生成随机数
假设概率密度函数为: 思路: 首先产生-1到1之间的均匀分布随机数x,和0到1之间的均匀分布随机数y. 如果y<f(x),则x是符合该概率密度的随机数,否则,重复上述操作. 用r语言生成100个 ...
- iOS显示PDF
使用UIWebView来显示 //locale file NSString *html = [NSString stringWithContentsOfFile:path1 encoding:NSUT ...
- poj 1715 Hexadecimal Numbers 排列组合
/** 大意: 给定16进制数的16个字母,,求第k大的数,,要求数的长度最大为8.,并且每个数互不相同. 思路: 从高到低挨个枚举,每一位能组成的排列数 ,拿最高位来说,能做成的排列数为15*A(1 ...
- (Problem 47)Distinct primes factors
The first two consecutive numbers to have two distinct prime factors are: 14 = 2 7 15 = 3 5 The fi ...
- Spring MVC 入门基础
欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入 原文链接:http://java.chinaitlab.com/advance/899129.html 基本上是一个精简版的 ...