# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1128713 | raisel | Bomb (IZhO17_bomb) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#define forn for(int i=1;i<=n;i++)
#define Yes cout<<"YES\n"
#define No cout<<"NO\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define pb push_back
#define sp setprecision
#define int long long
#define ll long long
#define nn '\n'
using namespace std;
const int N=2502;
const int MOD=1e9+7;
char a[N][N];
string ab="abcdefghijklmnopqrstuvwxyz";
int binpow(int n, int k) {
int ans = 1;
while (k > 0) {
if (k % 2 == 1) {
ans = (ans * n) % MOD;
}
n = (n * n) % MOD;
k /= 2;
}
return ans;
}
int n,m;
string s;
void al(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
int cnt=0;
vector<int>v;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='1') cnt++;
else {
if(cnt>0) v.pb(cnt);
cnt=0;
}
}
}
int x=v[0];
for(auto i:v){
int g=__gcd(x,i);
x=g;
}
cout<<x;
}
signed main(){
freopen("bomb.in","r",stdin);
freopen("bomb.out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t=1;
// cin>>t;
while(t--) {
al();
}
}
// x!
// 3! (x-3)!;
/*
2
1 1 1 1 1 1
1 2 3 4 5 6
1 2 3
1 2 4
1 2 5
1 2 6
1 3 4
1 3 5
1 3 6
1 4 5
1 4 6
1 5