链接: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 小模拟的更多相关文章

  1. HDU 4814 Golden Radio Base 模拟

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4814 题目大意: 把一个正整数表示为φ进制, φ = (1+√5)/2 . 且已知: 1. φ + 1 ...

  2. hdu 4814 Golden Radio Base

    详解见:http://blog.csdn.net/tri_integral/article/details/18666797 #include<cstdio> #include<cs ...

  3. HDU 4818 Golden Radio Base (2013长春现场赛B题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4814 进制转换. 现场根据题目给的两个公式,不断更新!!! 胡搞就可以了. 现场3A,我艹,一次循环开 ...

  4. ACM学习历程——HDU4814 Golden Radio Base(数学递推) (12年成都区域赛)

    Description Golden ratio base (GRB) is a non-integer positional numeral system that uses the golden ...

  5. 【10.6校内测试】【小模拟】【hash+线段树维护覆盖序列】

    一开始看到题就果断跳到T2了!!没想到T2才是个大坑,浪费了两个小时QAQ!! 就是一道小模拟,它怎么说就怎么走就好了! 为什么要用这么多感叹号!!因为统计答案要边走边统计!!如果每个数据都扫一遍20 ...

  6. hdu 3709 数字dp(小思)

    http://acm.hdu.edu.cn/showproblem.php?pid=3709 Problem Description A balanced number is a non-negati ...

  7. 【11.8校内测试】【倒计时2天】【状压DP】【随机化?/暴力小模拟】

    Solution 数据范围疯狂暗示状压,可是一开始发现状态特别难受. 将每一层的奇偶性状压,预处理所有状态的奇偶性.每一层的输入代表的其实可以是下一层某个点可以被从这一层哪些点转移到. 所以枚举每个状 ...

  8. hdu 4523 威威猫系列故事——过生日 小模拟

    威威猫系列故事——过生日 Time Limit: 500/200 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total ...

  9. HDU 5102 The K-th Distance(模拟)

    题意:输入一棵树,输出前k小的点对最短距离dis(i,j)的和. 模拟,官方题解说得很清楚了.不重复了. http://bestcoder.hdu.edu.cn/ 需要注意的是,复杂度要O(n+k), ...

随机推荐

  1. linux技术框架

    编程语言 一般使用c或者c++ linux使用 鸟哥私房菜 工具使用 代码编辑source insight,代码编译gcc,代码调试gdb,代码编译组织makefile,命令执行shell,文本编辑n ...

  2. HTML的标题样式

    标题样式1 <p> <span style=" text-align: center; padding-bottom: 6px; padding-left: 20px; p ...

  3. Java编程思想重点笔记

    首先声明转自https://github.com/lanxuezaipiao/ReadingNotes 无意中发现,写的蛮好转过来学习下. 1. Java中的多态性理解(注意与C++区分) Java中 ...

  4. Struts2 学习笔记15 Struts标签 part1

    来说一下Struts标签,之前我们也很多地方用到了,还是来总结一下. 首先是property标签. <li>property:<s:property value="user ...

  5. Linux 内核的编译系统

    Linux  的编译使用 GNU make 工具来检查整个系统的文件和调用 gcc 工具以及脚本完毕编译源码生成 image 等操作.要了解整个编译系统,我们首先要了解 Linux 内核的 Makef ...

  6. 最新VMware Workstation 10注册码,绝对可用!

    最近公司要在solaris上测试产品,需要用到虚拟机,于是下载了最新的虚拟机VMware Workstation 10,并找到了破解码,与大家共享: VMware workstation 10破解序列 ...

  7. tomcat的集群配置

    配置环境需要:1.Apache服务器,下载地址:http://httpd.apache.org/download.cgi#apache22 2.tomcat6.0或者tomcat7.0,(集群中tom ...

  8. jQ 操作积累

    1.判断radio是否选中:方式一:var val=$('input:radio[name="sex"]:checked').val(); //(val==null 未选中) 方式 ...

  9. bootstrap基础样式使用

    <small> 为了给段落添加强调文本,则可以添加 class="lead" <small>本行内容是在标签内</small><br> ...

  10. js得到分页栏

    自己写的,感觉返回html代码蠢蠢的,但是新手并不知道怎么写更好的,感觉这样子也蛮简单.记录下来,以后来越改越好. //获得分页栏.注意indexSize为奇数,这样也比较好看 //totalNum: ...