题目链接: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. android设置eclipse中的自动提示功能

    菜单window->Preferences->Java->Editor->Content Assist->Enable auto activation 选项要打上勾 (并 ...

  2. POJ 2404 Jogging Trails

    Jogging Trails Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2122   Accepted: 849 Des ...

  3. poj1459 Power Network --- 最大流 EK/dinic

    求从电站->调度站->消费者的最大流,给出一些边上的容量.和电站和消费者能够输入和输出的最大量. 加入一个超级源点和汇点,建边跑模板就能够了. 两个模板逗能够. #include < ...

  4. qt之正则表达式

    原地址:http://blog.csdn.net/phay/article/details/7304455 QRegExp是Qt的正则表达式类.Qt中有两个不同类的正则表达式.第一类为元字符.它表示一 ...

  5. 报错消息写在AT SELECTION-SCREEN OUTPUT和START-OF-SELECTION事件下的区别

    今天面试没答上来的问题,其实我是知道的,以前也遇到过.... START-OF-SELECTION下的话会在左下角报错 AT SELECTION-SCREEN OUTPUT消息会弹出框,然后点击就没有 ...

  6. Selenium Webdriver firefox 浏览器问题

    Selenium Webdriver 在使用firefox 测试会牵扯到firefox的安装路径的问题 1.默认安装路径在c盘的情况下: WebDriver driver = new FirefoxD ...

  7. mysql 分区和集群

    集群和分区:http://han-zw.iteye.com/blog/1662941http://www.php-note.com/article/detail/794 分区:http://lober ...

  8. POJ 3017 单调队列dp

    Cut the Sequence Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 8764   Accepted: 2576 ...

  9. OCX控件在IE中无法侦测到键盘消息( MFC ActiveX Control in IE Doesn't Detect Keystrokes)

    症状描述: Accelerator keys, such as ARROW keys, are first received by the message pump of the ActiveX co ...

  10. 浅析innodb_support_xa与innodb_flush_log_at_trx_commit

    很久以前对innodb_support_xa存在一点误解,当初一直认为innodb_support_xa只控制外部xa事务,内部的xa事务是mysql内部进行控制,无法人为干预(这里说的内部xa事务主 ...