zoukankan      html  css  js  c++  java
  • P1936 【水晶灯火灵】

    lalala~~(才不会告诉你这是题面呢)

    这题确实有点坑,第一遍穷举超时,然后就开始了漫漫找规律之路。。。

    终于,在经过5分钟的纠结之后,我终于发现了这个神奇的规律,那就是

    Fabonacci!!!

    好吧,这没什么值的兴奋的。。。

    具体解释看代码:

     1 #include<set>
     2 #include<map>
     3 #include<list>
     4 #include<queue>
     5 #include<stack>
     6 #include<string>
     7 #include<cmath>
     8 #include<ctime>
     9 #include<vector>
    10 #include<bitset>
    11 #include<memory>
    12 #include<utility>
    13 #include<cstdio>
    14 #include<sstream>
    15 #include<iostream>//其实本题只需要这一个头文件。。。
    16 #include<cstdlib>
    17 #include<cstring>
    18 #include<algorithm>//个人建议把会的头文件都写上去,以免出现未调用函数库的的命令
    19 using namespace std;
    20 long long k,a,b,c;//可爱的四个函数~~~
    21 int main(){//可爱的主程序~~~
    22     cin>>k;//可爱的输入~~~
    23     a=b=1;
    24     c=a+b;//可爱的赋初值~~~
    25     while(c<=k){//可爱的循环~~~
    26         a=b;
    27         b=c;
    28         c=a+b;//用三个数据循环模拟数组,起到节省空间的作用
    29     }
    30     cout<<"m="<<a<<endl;
    31     cout<<"n="<<b<<endl;//可爱的输出~~~
    32     return 0;
    33 }

    最后,祝大家编程顺利~~~

    新人开博,鼓励一下啦~~~

  • 相关阅读:
    navicat for mysql (本人亲测,真实有效)
    python 8 days
    python 19 days
    python 20 days
    python 21 days
    python 10 days
    python 9 days
    python 14 days
    python 15 days
    python 16 days
  • 原文地址:https://www.cnblogs.com/hahaha2124652975/p/11123107.html
Copyright © 2011-2022 走看看