zoukankan      html  css  js  c++  java
  • Codeforces Round #594 (Div. 1A) lvan the Fool and Probability Theory

    题意,一个只有黑白两色的矩阵

    称概率图为满足每一个方格上下左右四个方向只有一个方格颜色和当前方格颜色相同的图

    题解

    打表

    -0 2*1 2*2 2*3 2*5 2*8 2*13
    -1 2*2 2*3 2*4 2*6 2*9 2*14
    -2 2*3 2*4 2*5 2*7 2*10 2*15
    -4 2*5 2*6 2*7 2*9 2*11  
    -7 2*8 2*9 2*10 2*12 2*15  
    -12 2*13 2*14 2*15 2*17    

    发现每一行符合$f[i]=f[i-1]+f[i-2]-c$形式

    $c$符合$abs(c[i])=abs(c[i-1])+abs(c[i-2])+1$形式

    前两列也符合$f[i]=f[i-1]+f[i-2]-c$形式

    递推

    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long 
    #define A 1111111
    const ll mod=1e9+7;
    ll n,m,c;
    ll cha[A],thefirst[A],thesecond[A],ans[A];
    int main(){
        scanf("%lld%lld",&n,&m);
        cha[1]=0;cha[2]=1;
        thefirst[1]=1;thefirst[2]=2;
        thesecond[1]=2;thesecond[2]=3;//最后统一
        for(ll i=3;i<=100000;i++)
            cha[i]=(cha[i-1]+cha[i-2]+1)%mod;
        for(ll i=3;i<=100000;i++)
            thefirst[i]=(thefirst[i-1]+thefirst[i-2])%mod;
        for(ll i=3;i<=100000;i++)
            thesecond[i]=(thesecond[i-1]+thesecond[i-2]-1)%mod;
        ans[1]=thefirst[n]%mod;ans[2]=thesecond[n]%mod;
        c=cha[n];
    //  printf("1=%lld 2=%lld c=%lld
    ",ans[1],ans[2],c);
        for(ll i=3;i<=100000;i++)
            ans[i]=(ans[i-1]+ans[i-2]-c)%mod;
        printf("%lld
    ",(ans[m]*2%mod+mod)%mod);
    }
    View Code

    证明我当然不会

  • 相关阅读:
    使用Node.js和Redis实现push服务--转载
    phpredis中文手册——《redis中文手册》 php版--引用他人
    nginx path_info问题解决
    mysql 获取一个表中缺失的最小编号
    mysql row number的实现
    Redis应用场景-转载
    从MySQL到Redis 提升数据迁移的效率
    hdu2057
    进制转换
    有关C语言指针访问问题
  • 原文地址:https://www.cnblogs.com/znsbc-13/p/11770493.html
Copyright © 2011-2022 走看看