题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4814

题目大意:

把一个正整数表示为φ进制, φ = (1+√5)/2 。

且已知:

1. φ + 1 = φ 2 ,所以有11(φ)
= 100(φ),且要求11要转变为100

2. 2 *
φ 2  = φ3 +
1 。

解题思路:

观察发现,2 = 10.01。所以对于一个数N,能够从N/2 推导得到,是一个模拟的过程。我比赛的时候居然用了高速幂。。。

代码:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<numeric>
#include<iomanip>
#include<bitset>
#include<sstream>
#include<fstream>
#define debug puts("-----")
#define pi (acos(-1.0))
#define eps (1e-8)
#define inf (1<<30)
#define LL long long
using namespace std;
int str[400];
int tmp[400];
int n;
void out() {
int st, ed;
for (int i = 0; i < 400; i++) if (str[i]) {
st = i;
break;
}
for (int i = 399; i >= 0; i--) if (str[i]) {
ed = i;
break;
}
for (int i = st; i <= 200; i++) printf("%d", str[i]);
if (ed > 200) {
printf(".");
for (int i = 201; i <= ed; i++) printf("%d", str[i]);
}
puts("");
}
void gao(int str[], int tmp[]) {
for (int i = 0; i < 400; i++) str[i] += tmp[i];
int k = 0;
while(k < 400) {
if (str[k] >= 2) {
str[k - 1] += 1; str[k] -= 2; str[k + 2] += 1;
k--;
}
else if (k > 0 && str[k] == 1 && str[k - 1] == 1) {
str[k] = 0; str[k - 1] = 0; str[k - 2] += 1;
k -= 2;
}
else k++;
}
}
void fi_pow(int k) {
memset(tmp, 0, sizeof(tmp)); memset(str, 0, sizeof(str));
tmp[200] = 1;
while(k) {
if (k & 1) {
gao(str, tmp);
//out();
}
k >>= 1;
gao(tmp, tmp);
}
}
int main () {
while(~scanf("%d", &n)) {
if (n == 1) {
puts("1");
continue;
}
fi_pow(n);
out();
}
return 0;
}

HDU 4814 Golden Radio Base 模拟的更多相关文章

  1. HDU 4814 Golden Radio Base 小模拟

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4814 题意:黄金比例切割点是,如今要求把一个10进制的的数转化成一个phi进制的数,而且不能出现'11'的 ...

  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. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

  6. HDU 5948 Thickest Burger 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Thickest Burger Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  7. HDU 5920 Ugly Problem 【模拟】 (2016中国大学生程序设计竞赛(长春))

    Ugly Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  8. HDU 5873 Football Games 【模拟】 (2016 ACM/ICPC Asia Regional Dalian Online)

    Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  9. HDU 5504 GT and sequence 模拟

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5504 思路:模拟 代码: #include<stdio.h>//------杭电5504 ...

随机推荐

  1. linux登录windows服务器

    在公司同时也兼顾了王老师会议网站的任务,我喜欢用linux,而会议网站托管在windows系统上,虽然装了双系统,但我还是比较懒,不喜欢经常切换系统.还好,linux可以实现登录windows服务器. ...

  2. Get started - UIkit documentation

    Get started - UIkit documentation Get started Get familiar with the basic setup and structure of UIk ...

  3. android 打包 /${zipalign}&quot; error=2, No such file or directory

    当我更新完android L proview之后我的打包出问题了,报错/${zipalign}" error=2, No such file or directory 排查了一下午才知道 近 ...

  4. 在jsp页面下, 让eclipse完全支持HTML/JS/CSS智能提示(转)

      我们平时用eclipse开发jsp页面时智能提示效果不太理想,今天用了两个小时发现了eclipse也可以像Visual Studio 2008那样完全智能提示HTML/JS/CSS代码,使用ecl ...

  5. <转载>如果在浏览器网页标题栏左侧加自定义小图标

    效果如下: 首先制作一个16*16像素的ico格式的图片,命名为:favicon.ico,然后在网站head标签直接加入: <link rel="icon" href=&qu ...

  6. delphiXE调用Objective-c库

    http://stackoverflow.com/questions/16515218/xe4-firemonkey-ios-static-library-pascal-conversion-from ...

  7. 基于visual Studio2013解决C语言竞赛题之1060寻找回文数

       题目 解决代码及点评 /* 60. 回文数指左右数字对称的数,如121,2112都是回文数.回文数猜想:取一任意十进制数,将其倒过来,并将这两个数相加, 然后把这个相加的和倒过来再与 ...

  8. [欧拉回路+手动开栈] poj 1780 Code

    题目链接: http://poj.org/problem? id=1780 Code Time Limit: 1000MS   Memory Limit: 65536K Total Submissio ...

  9. Effective C++_笔记_条款12_复制对象时勿忘其每一个成分

    (整理自Effctive C++,转载请注明.整理者:华科小涛@http://www.cnblogs.com/hust-ghtao/) 编译器会在必要时候为我们的classes创建copying函数, ...

  10. 使用OVS

    创建节点: 需要在组件上引用OVS组件WDR_OVS:引用后需要更改添加节点属性值如下: 布局如下: 在view中也添加ovs组件 新建事件方法: ON_EVENT 代码如下: METHOD on_e ...