zoukankan      html  css  js  c++  java
  • poj 3734 Blocks

                                                                                            Blocks
    Time Limit: 1000MS Memory Limit: 65536K
    Total Submissions: 720 Accepted: 201

    Description

    Panda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of painting. Suppose there are N blocks in a line and each block can be paint red, blue, green or yellow. For some myterious reasons, Panda want both the number of red blocks and green blocks to be even numbers. Under such conditions, Panda wants to know the number of different ways to paint these blocks.

    Input

    The first line of the input contains an integer T(1≤T≤100), the number of test cases. Each of the next T lines contains an integer N(1≤N≤10^9) indicating the number of blocks.

    Output

    For each test cases, output the number of ways to paint the blocks in a single line. Since the answer may be quite large, you have to module it by 10007.

    Sample Input

    2
    1
    2

    Sample Output

    2
    6

    Source

    [Submit]   [Go Back]   [Status]   [Discuss]

    //

     这个题目

    //这个题目的规律就是:f(n)=4的n-1次方+2的n-1次方

    #include <iostream>
    using namespace std;

    int main()
    {
        
    int t , i;
        
    int n , ans;
        
    int ans2 , ans4;
        
    int tt;
        
        cin 
    >> t;
        
    while (t --)
        {
            cin 
    >> n;
            ans2 
    = 1;  ans4 = 1;

            tt 
    = (n - 1% 10006;
            
    for (i = 1 ; i <= tt ; ++ i)
            {
               ans2 
    *= 2;
               
    if (ans2 >= 10007)
                   ans2 
    %= 10007;
               ans4 
    *= 4;
               
    if (ans4 >= 10007)
                   ans4 
    %= 10007;
            }
            cout 
    << ( ans2 + ans4 ) % 10007 << endl;
        }
        
    return 0;
    }

  • 相关阅读:
    github登录不上?!
    js -- even-loop 理解
    前端面试积累(整理中)
    各个ctr算法的比较
    常用ctr算法比较
    BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
    Attention is All You Need
    理解word2vec
    EDA时的画图函数
    alphogo 理解
  • 原文地址:https://www.cnblogs.com/forever4444/p/1458765.html
Copyright © 2011-2022 走看看