暑假第一周 T
来源:互联网 发布:.net cms 源码 编辑:程序博客网 时间:2024/06/05 03:13
Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers.
Let's remember how Fibonacci numbers can be calculated. F0 = 0, F1 = 1, and all the next numbers are Fi = Fi - 2 + Fi - 1.
So, Fibonacci numbers make a sequence of numbers: 0, 1, 1, 2, 3, 5, 8, 13, ...
If you haven't run away from the PC in fear, you have to help the virus. Your task is to divide given Fibonacci number n by three not necessary different Fibonacci numbers or say that it is impossible.
The input contains of a single integer n (0 ≤ n < 109) — the number that should be represented by the rules described above. It is guaranteed that n is a Fibonacci number.
Output three required numbers: a, b and c. If there is no answer for the test you have to print "I'm too stupid to solve this problem" without the quotes.
If there are multiple answers, print any of them.
3
1 1 1
13
2 3 8
//T
#include <iostream>
using namespace std;
int main()
{
int i;
int a[100100];
a[0]=0,a[1]=1;
for(i=2;i<100100;i++){
a[i]=a[i-1]+a[i-2];
}
int n;
while(cin>>n){
for(i=0;i<100100;i++){
if(a[i]==n){
if(n==0){
cout<<a[0]<<" "<<a[0]<<" "<<a[0]<<endl;
break;
}else if(n==1){
cout<<a[0]<<" "<<a[0]<<" "<<a[1]<<endl;
break;
}else if(n==2){
cout<<a[0]<<" "<<a[1]<<" "<<a[1]<<endl;
break;
}else if(n==3){
cout<<a[1]<<" "<<a[1]<<" "<<a[1]<<endl;
break;
}
else if(n>3){
cout<<a[i-4]<<" "<<a[i-3]<<" "<<a[i-1]<<endl;
break;
}
}
}
}
return 0;
}
- 暑假第一周 T
- 暑假的第一周
- 暑假第一周 I
- 暑假第一周 L
- 暑假第一周 A
- 暑假第一周 R
- 暑假第一周 E
- 暑假第一周 B
- 暑假集训第一周总结
- 暑假学习任务第一周
- 暑假留校--第一周总结
- 暑假第一周学习总结
- 暑假留校第一周总结
- 2013年暑假实习第一周总结
- 2015暑假集训第一周题目总结
- WUST暑假集训第一周简单小结
- 暑假第一周 F (水题)
- 暑假第一周 D CodeForces 660 B.
- 网络知识总结
- [图像处理] 利用PerlinNoise实现图像雾化效果
- PAT乙级 1054. 求平均值 (20)
- 如何配置python环境和跑通第一个程序
- Java面试题-统计字符串的字符出现次数
- 暑假第一周 T
- 使用Mybatis模糊查询方法
- JS 函数的定义(一)
- VS使用SVN协同编程中遇到的小问题
- javascript实现二叉树的遍历
- Android异常解决之WindowManager.BadTokenException
- HDOJ 2036 改革春风吹满地
- Java中i++与++i区别
- 暑假第一周 G(中位数与平均数的比较)