当前位置:网站首页>The starting point of the final end of the 15th day of the sprint to the big factory
The starting point of the final end of the 15th day of the sprint to the big factory
2022-04-22 08:26:00 【It's a bubble】
Hello everyone , I'm a bubble , The purpose of bringing you a daily question is to better practice the algorithm , Our daily question is to let you practice all kinds of questions , Familiar with various question types , A year later , Transform into a different self !
Welcome to focus on the likes collection ️ Leaving a message.
️ : love C/C++ And algorithm learning , Cloud computing, etc , Looking forward to communication !
The author's level is limited , If an error is found , Please let me know , Thank you very much !
University algorithm learning community :https://bbs.csdn.net/forums/Suanfa
Join the army of brushing questions together , You can also join an exclusive inner volume group , There are a lot of benefits and a lot of big guys !
Catalog
Today's topic : The starting point of the end
Today's topic : The starting point of the end
The starting point of the end
Finally write down the period
Finally we say goodbye
Finally, we are back to the origin
……One by one OIer My competitive career always starts with NOIp Start , Most of them are also in a NOIp In the end , It's like reincarnation is on again and again .
If the NOIp Is your starting point , Then I wish you OI Life is as gorgeous as summer flowers .
If the NOIp It's your destination , Then I wish you OI Memories are as bright as stars .
Maybe this is your last time playing in the Los Angeles Valley , Maybe not. .
however , in any case , I wish you in the game in a week , Good luck .Of course , This question is also related to reincarnation .
Title Description
The well-known fiboracci sequence is calculated in this way
That is to say 0, 1, 1, 2, 3, 5, 8, 13 \cdots0,1,1,2,3,5,8,13⋯, Each is the sum of the first two .
Small F Find out , If each pair of fiboracci numbers is arbitrarily greater than 11 The positive integer MM When taking the mold , A sequence of numbers produces a loop .
Of course , Small F I soon understood , because (\mathrm{fib}(n - 1) \bmod Mfib(n−1)modM) and (\mathrm{fib}(n - 2) \bmod M)fib(n−2)modM) Only up to M2 Species value , So in M ^ 2M2 There must have been a cycle after this calculation .
Even more generally , We can prove that , Whatever modulus is taken M, Final die M The next fiboracci sequence will be ,0,1,⋯.
Now? , Give you a module M, Please find out the smallest n>0, bring M = 1fib(n)modM=0,fib(n+1)modM=1.
Input format
Enter a positive integer per line M.
Output format
Output a positive integer line by line n.
Topic analysis
questions :️️
The topic involves algorithms : Recurrence , violence .
ps: Capable partners can try to optimize their own code or solve more than one problem , This can comprehensively improve their algorithm ability
Problem solving report :
1. Ideas
use longlong Prevent explosion Then just direct violence simulation
2. Code
#include<stdio.h>
long long arr[10000002];
long long m;
long long fib(long long x)
{
if(arr[x])
{
return arr[x];
}
if(x==1||x==2)
{
return arr[x] = 1 % m;
}
else
{
return arr[x]=(fib(x-1)+fib(x-2))%m;
}
}
int main()
{
scanf("%lld",&m);
long long i=1;
while(fib(i)!=0||fib(i+1)!=1)
{
i++;
}
printf("%lld",i);
return 0;
}
版权声明
本文为[It's a bubble]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220711530627.html
边栏推荐
- On the modification of static database
- 信息学奥赛一本通 1317:【例5.2】组合的输出
- 深度Q-网络(DQN)
- EFCore全局查询筛选器
- 如何用c语言实现【猜数字游戏】
- Variant quick platoon: find the largest number of top k
- npm发布一个项目到npm库?
- js学习笔记
- MySQL advanced view -- View introduction, view crud syntax, check options (cascaded, local), view update, view function, view case
- Unity 透视投影矩阵变换的可视化
猜你喜欢

Leetcode 111 Balanced binary tree (2022.04.21)

Integrated service PDH optical transceiver 4-way Gigabit isolated Ethernet + 4-way E1 private network service 2m integrated service optical transceiver

16 way E1 optical transceiver + 4-way 100M Ethernet optical transceiver PDH optical transceiver 2m integrated service optical transceiver

Pycharm terminal PIP installation error: "PIP" item is recognized as the name of cmdlet, function, script file or runnable program

原来PID是在老王头和老斯基的斗争中诞生的

oh-my-notepro

国内云安全市场突破百亿元,未来发展趋势如何?

Redis非关系型数据库—Redis高可用、持久化及性能管理

What do you know about the well-known public DNS servers in China

qt designer 跳转,布局,样式
随机推荐
Hanyuan hi tech PDH optical transceiver double optical port protection + 4-way E1 + 4-way Gigabit Network + 4-way 100m network optical transceiver
ACM入门之【TSP问题】
综合光接入设备提供16路E1业务口4路百兆隔离网络2路千兆隔离以太网光端机
关闭电脑端口
电信级双光口保护8E1+4路物理隔离千兆网络光端机1000M网络100M光端机
光纤传输16路E1+4路千兆隔离以太网络光端机2M专网千兆以太网综合多业务PDH光端机
wepy学习记录
Magnesium oxide MgO crystal substrate | strontium titanate SrTiO3 crystal substrate | lithium niobate LiNbO3 crystal substrate; 10mm diameter
面经:
2-15 求组合数
Carrier grade double optical port protection 8e1 + 4-way physical isolation gigabit network optical transceiver 1000m network 100m optical transceiver
Goweb Foundation
提供4路E1业务口4路百兆隔离网络2M E1专网多业务PDH光端机
js学习笔记
變種快排:尋找最大的前K個數
Unity 透视投影矩阵变换的可视化
RSYNC及inotify远程同步
The collection palette in LabVIEW 2012 is imported into LabVIEW 2013
Provide 4-way E1 service ports, 4-way 100m isolation network, 2m E1 private network, multi service PDH optical transceiver
双光口1+1备份8路E1+2路千兆隔离网络4路百兆隔离PDH光端机
