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;
    }

  • 相关阅读:
    EM and GMM(Code)
    EM and GMM(Theory)
    安装Sphere v2.7 遇到的问题
    pyqt的 .ui 转换为 .py 后的操作注意事项
    SVM入门(一)
    关于范数的理解
    快速排序的C语言实现
    QT编程环境搭建
    flex布局左边固定,右边自适应,右边内容超出会影响布局
    未知宽高的div怎么垂直水平居中
  • 原文地址:https://www.cnblogs.com/forever4444/p/1458765.html
Copyright © 2011-2022 走看看