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

  • 相关阅读:
    批处理详细教程1
    “无后端”的web应用开发模式
    给Notepad++换主题
    Github for Windows使用图文教程
    MongoDB操作数据库的几个命令(自己用)
    P2P实现的原理
    ios中摄像头/相册获取图片压缩图片上传服务器方法总结
    ffmpeg编译
    UIScrollView的contentSize、contentOffset和contentInset属性
    sqllite相关总结
  • 原文地址:https://www.cnblogs.com/forever4444/p/1458765.html
Copyright © 2011-2022 走看看