当前位置:网站首页>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
边栏推荐
- 企业应用需求导向开发之人力部门,员工考勤记录和实发工资业务程序案例
- C method question 1
- Home appliance industry channel business collaboration system solution: help home appliance enterprises quickly realize the Internet of channels
- B_QuRT_User_Guide(40)
- MySQL Index Optimization Practice I
- Three questions TDM
- The for loop realizes 1-100 addition and eliminates the 4-digit tail number
- SAP HR 社会工作经历 0023
- 2022 certified surveyors are still at a loss when preparing for the exam? Teach you how to take the exam hand in hand?
- Solution of intelligent supply chain collaboration platform in electronic equipment industry: solve inefficiency and enable digital upgrading of industry
猜你喜欢
Three questions TDM
Benchmarking Detection Transfer Learning with Vision Transformers(2021-11)
2022第六季完美童模陕西总决赛圆满落幕
包装行业智能供应链S2B2B商城解决方案:开辟电商消费新生态
C method question 1
Design and implementation of spark offline development framework
UE4_ Ue5 panoramic camera
SAP HR family member information
C # exchange number, judge to pass the exam
激光slam学习(2D/3D、偏实践)
随机推荐
Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
postgis学习
保证接口数据安全的10种方案
Fibonacci number of dynamic programming
Arbre binaire équilibré [Arbre AVL] - Insérer et supprimer
包装行业智能供应链S2B2B商城解决方案:开辟电商消费新生态
0-1 knapsack problem
Oracle statistics by time
[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code
Navicat connects Oracle
0-1背包问题
【实验分享】通过Console口登录到Cisco设备
B_QuRT_User_Guide(36)
List. How to achieve ascending and descending sort() 2020.8.6
B_ QuRT_ User_ Guide(38)
Extract the file name under the folder under win
Boost regex library source code compilation
Idea automatically generates serialVersionUID
Oracle string sorting
Illegal behavior analysis 1