当前位置:网站首页>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
边栏推荐
猜你喜欢

高效的S2B2C电商系统,是这样帮助电子材料企业提升应变能力的

2022第六季完美童模陕西总决赛圆满落幕

ASP. Net core middleware request processing pipeline

C number of words, plus ¥, longest word, average value

Three questions TDM

Take you hand in hand to build feign with idea

Svn relocation

电子设备行业智能供应链协同平台解决方案:解决低效, 赋能产业数字化升级
![Balanced binary tree [AVL tree] - insert, delete](/img/1f/cd38b7c6f00f2b3e85d4560181a9d2.png)
Balanced binary tree [AVL tree] - insert, delete

Digital procurement management system for fresh food industry: help fresh food enterprises solve procurement problems and implement online procurement throughout the process
随机推荐
List. How to achieve ascending and descending sort() 2020.8.6
Live server usage
电子设备行业智能供应链协同平台解决方案:解决低效, 赋能产业数字化升级
ASP. Net core middleware request processing pipeline
B / Qurt Utilisateur Guide (36)
B_ QuRT_ User_ Guide(38)
SAP HR 家庭成员信息
B_QuRT_User_Guide(36)
[stm32+esp8266 connect Tencent cloud IOT development platform 2] stm32+esp8266-01s connect Tencent cloud
Lm12 rolling heikin Ashi double K-line filter
ESP at installation esp8266 and esp32 versions
S2b2b mall solution of intelligent supply chain in packaging industry: opening up a new ecosystem of e-commerce consumption
Svn relocation
Reverse output three digit and arithmetic sequence
C simple question 2
PCB wiring rules of PCI Express interface
[compilation principle] lexical analysis design and Implementation
webflux - webclient Connect reset by peer Error
Anti climbing means cracking the second
Deep understanding of MySQL lock and transaction isolation level