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), ...
随机推荐
- hdoj 3478 Catch(二分图判定+并查集)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3478 思路分析:该问题需要求是否存在某一个时刻,thief可能存在图中没一个点:将该问题转换为图论问题 ...
- 使用Lock实现信号量
public class SemaphoreOnLock { private final Lock lock = new ReentrantLock(); private fi ...
- [置顶] JDK-Future 模式和实现
最近的项目用到了多线程,发现java.util.concurrent.Future蛮好用的. 像平时,写多线程一般使用Thread/Runnable,直接扔给线程池执行就好了.但是遇到了一些需要获取线 ...
- Android API 中文(76)——AdapterView.OnItemLongClickListener
前言 本章内容是android.widget.AdapterView.OnItemLongClickListener,版本为Android 2.3 r1,翻译来自"cnmahj", ...
- JS,JQuery各种获取屏幕的宽度和高度
JQuery: $(document).ready(function(){ alert($(window).height()); //浏览器当前窗口可视区域高度 alert($(document).h ...
- 将从数据库中获取的数据 ,以HTML表格的形式显示
1.HTML页面 <body> <form id="form1" runat="server"> <div id="di ...
- JavaSE学习总结第17天_集合框架3
17.01 ArrayList集合的toString()方法源码解析 代码: Collection c = new ArrayList(); c.add("hello"); c ...
- python命令行解析工具argparse模块【5】
上一节我们学习了parse_args()的用法,这一节,我们将继续学习argparse的其他一些用法. 1.sub-commands子命令 argpar ...
- Android 开发笔记 “线程交互(Handler+Thread 和 AsyncTask)”
为什么需要线程 假设需要开发一个联网应用程序,需要从一个网址抓取网页内容,这里读取的网页地址是笔者在本地机器上自己建立的服务器地址.当然在读取网页内容的时候,可以使用HttpClient提供的API, ...
- Nginx阅读笔记(三)之proxy_pass用法
在nginx中配置proxy_pass时,当在后面的url加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走,如果没有/,则会把匹配的路径部分也给代理走. 假设访问 ...