844B

844B - Rectangles

最多有2^50*2个!!

我也用long long 了,可是移位的时候忘记了,导致溢出,然后一早起来发现被hack了=_=||

1<<temp;

1LL<<temp;

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const int maxn=1010;
 4 #define ll  long long
 5 int p[52][52];
 6 int n,m;
 7 
 8 int main(){
 9     while(scanf("%d%d",&n,&m)!=EOF){
10         ll ans=0;
11         for(int i=0;i<n;i++)
12             for(int j=0;j<m;j++) scanf("%d",&p[i][j]);
13         for(int i=0;i<n;i++){
14             ll temp=0;
15             for(int j=0;j<m;j++) if(p[i][j]==1) temp++;
16             ans+=(1LL<<temp)-1+(1LL<<(m-temp))-1;
17         }
18         for(int j=0;j<m;j++){
19             ll temp=0;
20             for(int i=0;i<n;i++) if(p[i][j]==1) temp++;
21             ans+=(1LL<<temp)-1+(1LL<<(n-temp))-1;
22         }
23         printf("%lld
",ans-1LL*n*m);
24     }
25 }
View Code
原文地址:https://www.cnblogs.com/yijiull/p/7426538.html