题解 | 压缩二维码
#include <iostream> #include <vector> #include <cmath> using namespace std; int main() { int n, count = 0, sum = 0;//count计数器,每4位输出一次,值存在sum中 char c; cin >> n; int length = pow(2,n);//取2的n次方 for(int i = 0; i< length*length; i++){ cin >> c; if(c=='.') sum += 0; else if(c=='#') sum += 1; count ++; if(count==4){ cout << sum << ' '; sum = 0; count = 0; } else { sum *= 2; } } return 0; } // 64 位输出请用 printf("%lld")