其他分享
首页 > 其他分享> > Codeforces 1182A Filling Shapes

Codeforces 1182A Filling Shapes

作者:互联网

题目链接: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 }

 

标签:cout,填充,int,sum,long,Shapes,Filling,ans,1182A
来源: https://www.cnblogs.com/Carered/p/11009641.html