zoukankan      html  css  js  c++  java
  • ZOJ 2872 Binary Partitions

    先写一个完全背包,然后找规律,然后打表。

    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    
    int a[2000000 + 100];
    int Zhong[2000000 + 100];
    int tot;
    int MOD = 1000000;
    
    int main()
    {
        a[0] = 1;
        a[1] = 1;
        a[2] = 2;
        a[3] = 2;
        int i = 4;
        tot = 0;
        int k = 0;
        Zhong[tot] = 2;
        while (1)
        {
            if (i > 2000000) break;
            a[i] = (a[i - 1] + Zhong[k]) % MOD;
            a[i + 1] = (a[i - 1] + Zhong[k]) % MOD;
            tot++; Zhong[tot] = a[i + 1] % MOD;
            a[i + 2] = (a[i + 1] + Zhong[k]) % MOD;
            a[i + 3] = (a[i + 1] + Zhong[k]) % MOD;
            tot++; Zhong[tot] = a[i + 3] % MOD;
            k++;
            i = i + 4;
        }
        int n;
        int T;
        scanf("%d", &T);
        while (T--)
        {
            scanf("%d", &n);
            printf("%d
    ", a[n] % MOD);
        }
        return 0;
    }
  • 相关阅读:
    [BZOJ1584][Usaco2009 Mar]Cleaning Up 打扫卫生
    CSS浮动
    Django by example -----1总结
    C#函数重载
    linux目录的特点
    Linux调优
    linux
    对齐方式
    19-10-25-G-悲伤
    19-10-24-H
  • 原文地址:https://www.cnblogs.com/zufezzt/p/4779470.html
Copyright © 2011-2022 走看看