谭飞云


私信TA

用户名:tfy2020

访问量:563

签 名:

等  级
排  名 2653
经  验 2142
参赛次数 8
文章发表 3
年  龄 0
在职情况 学生
学  校 鄂州职业大学
专  业

  自我简介:

TA的其他文章

DNA题解(java)
浏览:105

解题思路:

注意事项:

参考代码:

import java.util.Scanner;


public class A1429 {


public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

int m = sc.nextInt();

int n = sc.nextInt();

int [][]arr= new int[m][n];

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

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

arr[i][j]=sc.nextInt();

}

}

int x =sc.nextInt();

int y =sc.nextInt();

String s = sc.next();

int k = sc.nextInt();

int a = 0;

switch (s) {

case "U":a=1000;

break;

case "R":a=1001;

break;

case "D":a=1002;

break;

case "L":a=1003;

break;


default:

break;

}

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

if(arr[x][y]==1) {

a++;

arr[x][y]=0;

}else {

a--;

arr[x][y]=1;

}

switch (a%4) {

case 0:

x--;

break;

case 1:

y++;

break;

case 2:

x++;

break;

case 3:

y--;

break;


default:

break;

}

}

System.out.println(x+" "+y);

}


}


 

0.0分

0 人评分

  评论区