Educational Codeforces Round 59 (Rated for Div. 2) D. Compression 暴力

题目链接:

传送门

代码如下:

#include <bits/stdc++.h>
using namespace std;
const int maxn=5205;
int n;
string a[maxn];
int Judge (int x)
{
    for (int i=0;i<n;i+=x)
    {
        for (int j=0;j<n;j+=x)
        {
            char t=a[i][j];
            for (int k=i;k<i+x;k++)
            {
                for (int l=j;l<j+x;l++)
                {
                    if(a[k][l]!=t)
                        return 0;
                }
            }
        }
    }
    return 1;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for (int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        for (int j=0;j<s.size();j++)
        {
            if(s[j]=='0')
            {
                a[i]+="0000";
            }
            else if(s[j]=='1')
            {
                a[i]+="0001";
            }
            else if(s[j]=='2')
            {
                a[i]+="0010";
            }
            else if(s[j]=='3')
            {
                a[i]+="0011";
            }
            else if(s[j]=='4')
            {
                a[i]+="0100";
            }
            else if(s[j]=='5')
            {
                a[i]+="0101";
            }
            else if(s[j]=='6')
            {
                a[i]+="0110";
            }
            else if(s[j]=='7')
            {
                a[i]+="0111";
            }
            else if(s[j]=='8')
            {
                a[i]+="1000";
            }
            else if(s[j]=='9')
            {
                a[i]+="1001";
            }
            else if(s[j]=='A')
            {
                a[i]+="1010";
            }
            else if(s[j]=='B')
            {
                a[i]+="1011";
            }
            else if(s[j]=='C')
            {
                a[i]+="1100";
            }
            else if(s[j]=='D')
            {
                a[i]+="1101";
            }
            else if(s[j]=='E')
            {
                a[i]+="1110";
            }
            else if(s[j]=='F')
            {
                a[i]+="1111";
            }
        }
    }
    int ans;
    for (int i=1;i<=n;i++)
    {
        if(n%i==0)
        {
            if(Judge(i))
            {
                ans=i;
            }
        }
    }
    cout<<ans;
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值