HDOJ 4814 Golden Radio Base
来源:互联网 发布:时间 小人 js插件 编辑:程序博客网 时间:2024/06/07 05:40
利用题目中给出的公式和hint可以得到两个有用的公式:
phi^(n) = phi^(n-1)+phi^(n-2)
2*(phi^n) = phi^(n+1)+phi^(n-2)
可以计算出phi^100远大于10^9,所以推测最后得到的phi进制的数整数和小数部分应该不会超过100位,事实表明,50位就能过。
所以最终变成了简单的模拟。
Golden Radio Base
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 363 Accepted Submission(s): 165
Problem Description
Golden ratio base (GRB) is a non-integer positional numeral system that uses the golden ratio (the irrational number (1+√5)/2 ≈ 1.61803399 symbolized by the Greek letter φ) as its base. It is sometimes referred to as base-φ, golden mean base, phi-base, or, phi-nary.
Any non-negative real number can be represented as a base-φ numeral using only the digits 0 and 1, and avoiding the digit sequence "11" – this is called a standard form. A base-φ numeral that includes the digit sequence "11" can always be rewritten in standard form, using the algebraic properties of the base φ — most notably that φ + 1 = φ 2 . For instance, 11(φ) = 100(φ). Despite using an irrational number base, when using standard form, all on-negative integers have a unique representation as a terminating (finite) base-φ expansion. The set of numbers which possess a finite base-φ representation is the ring Z[1 + √5/2]; it plays the same role in this numeral systems as dyadic rationals play in binary numbers, providing a possibility to multiply.
Other numbers have standard representations in base-φ, with rational numbers having recurring representations. These representations are unique, except that numbers (mentioned above) with a terminating expansion also have a non-terminating expansion, as they do in base-10; for example, 1=0.99999….
Coach MMM, an Computer Science Professor who is also addicted to Mathematics, is extremely interested in GRB and now ask you for help to write a converter which, given an integer N in base-10, outputs its corresponding form in base-φ.
Any non-negative real number can be represented as a base-φ numeral using only the digits 0 and 1, and avoiding the digit sequence "11" – this is called a standard form. A base-φ numeral that includes the digit sequence "11" can always be rewritten in standard form, using the algebraic properties of the base φ — most notably that φ + 1 = φ 2 . For instance, 11(φ) = 100(φ). Despite using an irrational number base, when using standard form, all on-negative integers have a unique representation as a terminating (finite) base-φ expansion. The set of numbers which possess a finite base-φ representation is the ring Z[1 + √5/2]; it plays the same role in this numeral systems as dyadic rationals play in binary numbers, providing a possibility to multiply.
Other numbers have standard representations in base-φ, with rational numbers having recurring representations. These representations are unique, except that numbers (mentioned above) with a terminating expansion also have a non-terminating expansion, as they do in base-10; for example, 1=0.99999….
Coach MMM, an Computer Science Professor who is also addicted to Mathematics, is extremely interested in GRB and now ask you for help to write a converter which, given an integer N in base-10, outputs its corresponding form in base-φ.
Input
There are multiple test cases. Each line of the input consists of one positive integer which is not larger than 10^9. The number of test cases is less than 10000. Input is terminated by end-of-file.
Output
For each test case, output the required answer in a single line. Note that trailing 0s after the decimal point should be wiped. Please see the samples for more details.
Sample Input
123610
Sample Output
110.01100.011010.000110100.0101Hint
Source
2013 Asia Regional Changchun
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int base=100;int n;int wei[220];int main(){ while(scanf("%d",&n)!=EOF) { memset(wei,0,sizeof(wei)); wei[base]=n; while(true) { bool flag=false; for(int i=0;i<200;i++) { if(wei[i]>1) { int t=wei[i]; wei[i]=t%2; wei[i+1]+=t/2; wei[i-2]+=t/2; flag=true; } } for(int i=0;i<200;i++) { if(wei[i]&&wei[i+1]) { int t=min(wei[i],wei[i+1]); wei[i]-=t; wei[i+1]-=t; wei[i+2]+=t; flag=true; } } if(flag==false) break; } int st=-1,ed=-1; for(int i=0;i<202;i++) if(wei[i]) { st=i; break; } for(int i=202;i>=0;i--) if(wei[i]) { ed=i; break; } for(int i=ed;i>=st;i--) { printf("%d",wei[i]); if(i==base&&st!=i) putchar('.'); } putchar(10); } return 0;}
0 0
- HDOJ 4814 Golden Radio Base
- HDOJ 4814 Golden Radio Base【推公式 + 暴力】
- HDU 4814 Golden Radio Base
- HDU 4814 Golden Radio Base
- HDU 4814 Golden Radio Base
- HDU 4814 Golden Radio Base
- HDU 4814 Golden Radio Base
- HDU 4814 Golden Radio Base
- [hdu 4814]Golden Radio Base 找规律
- HDU 4814 Golden Radio Base 小模拟
- HDU 4814 Golden Radio Base 模拟
- hdu 4814 Golden Radio Base(数学模拟)
- hdu4814 Golden Radio Base
- HDU - 4814 Golden Radio Base (长春赛区B题)
- HDU 4814 Golden Radio Base 数学 模拟 或者乱搞。。。。
- 2013ICPC长春 HDU 4814 Golden Radio Base 乱搞
- 2013 Asia Regional Changchun HDU - 4814 Golden Radio Base (进制模拟)
- HDU 4814 Golden Radio Base(2013 ACM/ICPC 长春赛区现场赛)
- 如何在mac上安装gradle
- File类的文件访问
- cocos2dx-3.0 中的物理引擎Box2D使用(二)
- 搭建一个服务器框架,进程间利用管道通信,线程处理数据
- Python模块包中__init__.py文件的作用
- HDOJ 4814 Golden Radio Base
- 本地破解QQ密码
- Codeforces #263 div2 解题报告
- 图形浏览器
- inserAfter函数(js公共函数,类似insertBefore)
- oracle中的数值函数整理
- Linux 路由 学习笔记 之三 路由查找流程分析
- Metasploit - Tips for Evading Anti-Virus
- protobuf问题总结