当前位置:网站首页>C - Fibonacci sequence again
C - Fibonacci sequence again
2022-07-07 23:39:00 【Yuesi】
There is another Fibonacci sequence :
F0=7,F1=11,Fn=Fn−1+Fn−2 (n>=2).
Input format
The input data consists of multiple lines , On each line is an integer
n(n≤10^6).
Output format
If Fn Can be 3 to be divisible by , Then print a line "yes", otherwise , Print a row "no".
Tips
First use the array 1∼10^6 Of Fi
Work it out , Then every time you query , Otherwise it will time out .
The sample input
0
1
2
3
4
5
Sample output
no
no
yes
no
no
no
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int ans[1000006]={
0};// Store data
ans[0]=7;
ans[1]=11;
for(long long int i=2;i<=1000001;i++){
ans[i]=ans[i-1]%3+ans[i-2]%3;
// Just judge whether it can be 3 Divisible and easy to explode longlongint
// Therefore, there is no need to store the specific data of fibola series
}
long long int n;
while(scanf("%lld",&n)!=EOF){
if(ans[n]%3==0){
printf("yes\n");
}else{
printf("no\n");
}
}
return 0;
}
Pit point :
Large amount of data and easy to exceed the data range longlongint Range
边栏推荐
猜你喜欢
B_ QuRT_ User_ Guide(36)
MySQL Architecture
Interface
Live-Server使用
Pycharm essential plug-in, change the background (self use, continuous update) | CSDN creation punch in
B_QuRT_User_Guide(38)
As a new force, chenglian premium products was initially injected, and the shares of relevant listed companies rose 150% in response
One week learning summary of STL Standard Template Library
C inheritance and interface design polymorphism
2022 Season 6 perfect children's model Shaanxi finals came to a successful conclusion
随机推荐
Anti climbing means cracking the second
Come on, brother
SAP HR labor contract information 0016
One of the anti climbing methods
Have all the fresh students of 2022 found jobs? Is it OK to be we media?
648. Word replacement
Windows set redis to start automatically
B_ QuRT_ User_ Guide(39)
B_QuRT_User_Guide(39)
postgres timestamp转人眼时间字符串或者毫秒值
数据分析系列 之3σ规则/依据拉依达准则来剔除异常值
webflux - webclient Connect reset by peer Error
SLAM面试总结
Idea automatically generates serialVersionUID
二叉排序树【BST】——创建、查找、删除、输出
SAP HR family member information
Pycharm essential plug-in, change the background (self use, continuous update) | CSDN creation punch in
高效的S2B2C电商系统,是这样帮助电子材料企业提升应变能力的
Interface
As a new force, chenglian premium products was initially injected, and the shares of relevant listed companies rose 150% in response