题目链接:http://codeforces.com/problemset/problem/1182/A
思路:n为奇数时不可能完全填充,ans = 0。发现若要完全填充,每俩列可产生俩种情况,所以为 ans = 2n/2
AC代码:
1 #include<bits/stdc++.h> 2 using namespace std; 3 long long n,ans; 4 long long quickPow(long long a,long long b){ 5 int sum=1; 6 while(b){ 7 if(b&1) sum=sum*a; 8 b>>=1; 9 a=a*a; 10 } 11 return sum; 12 } 13 int main(){ 14 long long n; 15 cin >> n; 16 if(n % 2) cout << 0; 17 else cout << quickPow(2,n/2); 18 return 0; 19 }