• BZOJ1002: [FJOI2007]轮状病毒


    n<=100的形如的图有多少生成树。不取模。

    $f(i)=3*f(i-1)-f(i-2)+2$,VFK的题解

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<algorithm>
     4 #include<stdlib.h>
     5 //#include<queue>
     6 #include<math.h>
     7 //#include<time.h>
     8 //#include<iostream>
     9 using namespace std;
    10 
    11 int n;
    12 #define maxn 311
    13 const int base=100000000;
    14 struct LLL
    15 {
    16     int num[maxn],len;
    17     LLL() {len=0; memset(num,0,sizeof(num));}
    18     void operator = (int x)
    19     {
    20         if (x==0) {num[len=1]=0; return;}
    21         while (x) {num[++len]=x%base; x/=base;}
    22     }
    23     LLL operator + (const LLL &b)
    24     {
    25         LLL ans;
    26         for (int i=1,top=ans.len=max(len,b.len);i<=top;i++)
    27         {
    28             ans.num[i]+=(i<=len?num[i]:0)+(i<=b.len?b.num[i]:0);
    29             if (ans.num[i]>=base)
    30             {
    31                 ans.num[i]-=base;
    32                 ans.num[i+1]++;
    33             }
    34         }
    35         ans.len+=(ans.num[ans.len+1]>0);
    36         return ans;
    37     }
    38     LLL operator - (const LLL &b)
    39     {
    40         LLL ans;
    41         for (int i=1,top=ans.len=len;i<=top;i++)
    42         {
    43             ans.num[i]+=num[i]-(i<=b.len?b.num[i]:0);
    44             if (ans.num[i]<0)
    45             {
    46                 ans.num[i]+=base;
    47                 ans.num[i+1]--;
    48             }
    49         }
    50         ans.len-=(ans.num[ans.len]==0);
    51         return ans;
    52     }
    53     LLL operator + (int b)
    54     {
    55         LLL tmp; tmp=b;
    56         return *this+tmp;
    57     }
    58     void print()
    59     {
    60         printf("%d",num[len]);
    61         for (int i=len-1;i;i--) printf("%08d",num[i]);
    62     }
    63 };
    64 
    65 LLL a[maxn];
    66 int main()
    67 {
    68     scanf("%d",&n);
    69     a[1]=1; a[2]=5;
    70     for (int i=3;i<=n;i++) a[i]=a[i-1]+a[i-1]+a[i-1]-a[i-2]+2;
    71     a[n].print();
    72     return 0;
    73 }
    View Code
  • 相关阅读:
    Spark集群安装与配置
    Kafka集群的安装和部署
    Sqoop的安装和验证
    Zookeeper与HBase的安装
    Hive的安装
    在Eclipse中开发MapReduce程序
    HDFS基本命令与Hadoop MapReduce程序的执行
    Hadoop环境部署
    Java基础(十七)日志(Log)
    Java基础(十六)断言(Assertions)
  • 原文地址:https://www.cnblogs.com/Blue233333/p/8133764.html
Copyright © 2020-2023  润新知