zoukankan      html  css  js  c++  java
  • Blocks

     
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 6740   Accepted: 3276

    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
    #include <iostream>
    using namespace std;
    const int mod=10007;
    int pow(int a,int b){//quilck_^
        int ans=1,p=a;//make ans as 1,p as a
        while(b){//if b isnot 0 ,just go on
            if(b%2==1)ans=(ans*p)%mod;//if b is an odd number ,
            //just let the ans multiply the given base_number and % the given mod
            //!!if you don't %,maybe it at first larger than the range of int
            b=b/2;p=(p*p)%mod;//let the index been divided by 2
            //and renew the p ,and let it % the given mod
            }    //if b is 0 , just means has ^ already ,just break
        return ans;    //then return the ans
      }
    int main(){int t;
        scanf("%d",&t);//given case_number
        while(t--){int n;scanf("%d",&n);//depend on the case_number 
            printf("%d
    ",(pow(4,n-1)+pow(2,n-1))%mod);    
            //after matrix eigenvalues 
        }return 0;    
    } 
    //4^n=(2+1+1)^4,ans=sum[i=0...n]
    //(c(n,i)2^i*sum[k=n-i and it is an even_number,t=0,2,...k](c(k,t) );
    //at last work out 4^(n-1)+2^(n-1)。
    //blocks

    program is above, the program is the best language

  • 相关阅读:
    磁盘上没有足够的空间完成此操作的解决办法_Windows小知识
    使用XAMPP和DVWA在Windows7上搭建渗透测试环境
    使用WampServer和DVWA在Windows10上搭建渗透测试环境
    DOS系统常用命令
    Kali Linux图形界面与命令行界面的切换
    SQLMap入门之在Windows上安装SQLMap
    在Windows下同时安装Python2.x和Python3.x
    Python基础之Windows下Python3.x环境搭建
    在Linux上使用PGP签名验证文件完整性
    Ubuntu软件中心的完全启用
  • 原文地址:https://www.cnblogs.com/muzu/p/7145094.html
Copyright © 2011-2022 走看看