本文主要是介绍codeforces 426B - Sereja and Mirroring,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目链接:点击打开链接
题目分析:简单对称;
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int map[105][105], n, m, ans;
int main()
{//freopen("in.txt","r",stdin);int i, j, flag;while(scanf("%d%d", &n, &m)!=EOF){ans = n; flag=0;for(i=1; i <= n; i++)for(j=1; j <= m; j++)scanf("%d",&map[i][j]);while(ans%2==0){for(i=1; i<= ans/2; i++)for(j=1; j<= m; j++)if(map[i][j] != map[ans-i+1][j]){flag = 1;}if(flag==1) break;ans/=2;}printf("%d\n", ans);}return 0;
}
#include <cstdio>
#include <bitset>
using std::bitset;bitset<128> a[128];
int n,m,l,d;bool sym()
{if (l&1) return false;for (int i=0;i+i<l;++i) if (a[i]!=a[l-1-i]) return false;return true;
}
int main()
{scanf("%d%d",&n,&m);for (int i=0;i<n;++i) for (int j=0;j<m;++j){scanf("%d",&d);if (d==1) a[i].set(j);}for (l=n;sym();l/=2);printf("%d",l);return 0;
}
这篇关于codeforces 426B - Sereja and Mirroring的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!