zoukankan      html  css  js  c++  java
  • hdu 2067 “红色病毒”问题

    http://acm.hdu.edu.cn/showproblem.php?pid=2065

    据说这是一个母函数指数型,可是我看了半天觉得还是没有感觉,觉得还是递推比较好,直接看代码可能不懂,但是推理过程太麻烦。。。

    就是从n-1个来确定第n个,这样一步一步找到规律

    代码:

    #include <stdio.h>

    #include <string.h>

    #include <stdlib.h>

    #include <math.h>

    int main()

    {

        __int64 n;

        int t;

        int a[23]={0,2,6,20,72,72,56,60,12,92,56,0,52,12,56,40,92,32,56,80,32,52,56};

        int b[20]=      {20,72,72,56,60,12,92,56,0,52,12,56,40,92,32,56,80,32,52,56};

        /*可以用for(j=4;j<=30;j++)

        a[j]=((int)(pow(4,j-1)+pow(2,j-1)))%100;

        求出*/

        while(scanf("%d",&t),t)

        {

              for(int i=1;i<=t;++i)

              {

                        scanf("%I64d",&n);

                        if(n<=22)

                        printf("Case %d: %d\n",i,a[n]);

                        else

                        {

                            n=(n-3)%20;

                            printf("Case %d: %d\n",i,b[n]);

                        }

              }

              puts("");

        }

        return 0;

    }

  • 相关阅读:
    Pycharm5注册方式
    五、监听共享目录文件
    三、python webservice
    二、Python安装扩展库
    一、Python安装下载
    test
    拖延
    要乐观对待生活
    乞讨者
    不要总是指责和埋怨
  • 原文地址:https://www.cnblogs.com/yuelingzhi/p/2136601.html
Copyright © 2011-2022 走看看