#37204: java版


zhoudaniel02@gmail.com (周孝倫)

學校 : 銘傳大學
編號 : 235507
來源 : [114.136.10.77]
最後登入時間 :
2024-05-19 11:28:27
k732. 2. 特殊位置 -- 2023年6月APCS | From: [114.136.209.94] | 發表日期 : 2023-08-24 16:30

package apcsPrat;

import java.util.*;

public class JAVA {

public static void main(String [] args) {

Scanner sc=new Scanner(System.in);

int sup=0;

String [] s=sc.nextLine().split(" ");

int X=Integer.parseInt(s[1]),Y=Integer.parseInt(s[0]);

int [][] a=new int [Y][X];

for(int i=0;i<Y;i++) {

s=sc.nextLine().split(" ");

for(int j=0;j<X;j++)

a[i][j]=Integer.parseInt(s[j]);

}

List<String>spot=new ArrayList<>();

for(int y=0;y<Y;y++)

for(int x=0;x<X;x++) {

int val=a[y][x];

int total=0;

for(int j=0;j<=val;j++) {

for(int i=y-val+j;i<=y+val-j;i++) {

if(i<Y&&i>=0&&x-j>=0) {

total+=a[i][x-j];

}

if(j!=0)

if(i<Y&i>=0&&x+j<X) {

total+=a[i][x+j];

}

}

}

if(total%10==val) {

sup++;

spot.add(y+" "+x);

}

}

System.out.println(sup);

for(String e:spot)

System.out.println(e);

sc.close();

}

}

 
ZeroJudge Forum