链接: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. CMake 教程

    CMake是一个跨平台的程序构建工具,比如起自己编写Makefile方便很多. 介绍:http://baike.baidu.com/view/1126160.htm 本文件不介绍CMake的基本语法, ...

  2. Java面试题收集学习整理1

    1.java序列化.反序列化及serialVersionUID作用 ."=="和equals方法究竟有什么区别? .静态变量和实例变量的区别? 在语法定义上的区别:.Integer ...

  3. Android_Dialog_设置Dialog窗体的大小

    /** * 设置Dialog窗体的大小 */ private void setWindowSize() { DisplayMetrics dm = new DisplayMetrics(); Wind ...

  4. Android调用系统关机与重启功能

    我是在android源码里编译的package/apps/,因为需要调用的关机接口是不对上层开放的,在eclipse里面不能调用. 我主要是介绍调用android的关机功能,因为在调试过程中,关机的一 ...

  5. [LeetCode] Longest Substring Without Repeating Characters (LinkedHashSet的妙用)

    Given a string, find the length of the longest substring without repeating characters. For example, ...

  6. c 计算Fibonacci数列:1,1,2,3,5,8,13……这题也是很经典。

    输出数字序列2/,/,/,/,/,/...,输出个数由键盘输入.注意输入使用scanf输入 比如: 输入 3输出为 / / / 输入 输出为 / / / / #include<stdio.h&g ...

  7. C# Best Practices - Creating Good Methods

    How to Define a Method Identify the problem => Define the single purpose => Specify the inputs ...

  8. HTML5 总结-SVG-5

    HTML5 内联 SVG HTML5 支持内联 SVG. 什么是SVG? SVG 指可伸缩矢量图形 (Scalable Vector Graphics) SVG 用于定义用于网络的基于矢量的图形 SV ...

  9. nfs:server is not responding,still trying 原因与解决

    方案(学自他人) nfs:server is not responding,still trying的解决方法 (2009-04-20 10:20) 方法1 : 我在arm上通过NFS共享文件时出现下 ...

  10. WebHdfs

    https://github.com/ihrwein/webhdfs https://tiborbenke.blogs.balabit.com/2013/11/the-syslog-ng-in-the ...