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

  • 相关阅读:
    apicloud 运费计算js+页面
    css让字体细长
    vue 请求完接口后执行方法
    js监听当前页面再次加载
    用apicloud+vue的VueLazyload实现缓存图片懒加载
    git merge和git rebase的区别(转)
    yuan先生博客链接
    django组件之contenttype(一)
    Django的orm中get和filter的不同
    python第三方库requests详解
  • 原文地址:https://www.cnblogs.com/forever4444/p/1458765.html
Copyright © 2011-2022 走看看