⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2845649_re.java

📁 北大大牛代码 1240道题的原代码 超级权威
💻 JAVA
字号:
/*
 * Main.java
 *
 * Created on 2007年10月29日, 下午9:12
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package javaapplication1;
import java.util.*;
import java.math.*;
/**
 *
 * @author 张国文
 */
public class Main {
  
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner cin = new Scanner (System.in);
        int n, i, j, k, r, t, x;
        int map[][] = new int [371][371];
        int ansi, ansj, ans;
        Random r1 = new Random(); 
        Random r2 = new Random(); 
        
        n = cin.nextInt();
        for(i = 1; i <= n; i++)
            for(j = 1; j <= n; j++)
                map[i][j] = cin.nextInt();
        t = 30000;
        ansi = ansj = ans = 1;
        while(t!=0)
        {
            t--;
            i = (r1.nextInt()%n+n)%n+1;
            j = (r2.nextInt()%n+n)%n+1;
            x = n-i;
            if( x > n-j )x = n-j;
            if( x < ans )continue;
            for( k = x; k >= ans; k-- )
            {
                for( r = 0; r <= k; r++ )
                {
                    if( !( map[i][j+r] == map[i+k][j+r] && map[i+r][j] == map[i+r][j+k] ) )break;
                }
                if( r > k )
                {
                    ansi = i;
                    ansj = j;
                    ans = k+1;
                    break;
                }
            }
        }
        System.out.println(ansi+" "+ansj+" "+ans);
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -