当前位置:网站首页>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
边栏推荐
- ESP at installation esp8266 and esp32 versions
- As a new force, chenglian premium products was initially injected, and the shares of relevant listed companies rose 150% in response
- B_ QuRT_ User_ Guide(38)
- How can we make money by making video clips from our media?
- Lm12 rolling heikin Ashi double K-line filter
- 通达信买基金安全吗?
- Extract the file name under the folder under win
- C simple question 2
- Three questions TDM
- SAP HR 劳动合同信息 0016
猜你喜欢
家用电器行业渠道商协同系统解决方案:助力家电企业快速实现渠道互联网化
Anxinco esp32-a1s development board is adapted to Baidu dueros routine to realize online voice function
[STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware
USB (XV) 2022-04-14
Live-Server使用
UE4_ Ue5 combined with Logitech handle (F710) use record
SAP HR labor contract information 0016
高效的S2B2C电商系统,是这样帮助电子材料企业提升应变能力的
Markdown
MySQL Architecture
随机推荐
【7.5】15. Sum of three numbers
Interface
Fibonacci number of dynamic programming
【汇总】看过的一些Panel与视频
How to login and enable synchronization function in Google browser
C simple question 2
Possible SQL for Oracle table lookup information
Arbre binaire équilibré [Arbre AVL] - Insérer et supprimer
Ora-01741 and ora-01704
高效的S2B2C电商系统,是这样帮助电子材料企业提升应变能力的
ESP at installation esp8266 and esp32 versions
USB (XIV) 2022-04-12
May day d-light
Svn relocation
2022第六季完美童模陕西总决赛圆满落幕
进度播报|广州地铁七号线全线29台盾构机全部完成始发
SAP 内存参数调优过程
Where are you going
Mobile heterogeneous computing technology - GPU OpenCL programming (basic)
Anxinco EC series modules are connected to the multi protocol access products of onenet Internet of things open platform