본문 바로가기
GAME/www.codingame.com

Power of Thor

by 므시칸곰틔군 2015. 2. 10.

import java.util.*;

import java.io.*;

import java.math.*;


/**

 * Auto-generated code below aims at helping you parse

 * the standard input according to the problem statement.

 **/

class Player {


    public static void main(String args[]) {

        Scanner in = new Scanner(System.in);

      

        int LX = in.nextInt(); // the X position of the light of power

        int LY = in.nextInt(); // the Y position of the light of power

        int TX = in.nextInt(); // Thor's starting X position

        int TY = in.nextInt(); // Thor's starting Y position


        String str  ="";

        

        //로그...

        System.err.println("도착지 X  :"+ LX);

        System.err.println("도착지 Y   :"+ LY);

        System.err.println("    ");

        System.err.println("출발지 X   :"+ TX);

        System.err.println("출발지 Y   :"+ TY);


        // game loop

        while (true) {

            

            int E = in.nextInt(); // The level of Thor's remaining energy, representing the number of moves he can still make.

          

            //동서남북.

            if(LX > TX && LY == TY){

                str ="E";

            }else if(LX < TX && LY == TY){

                str ="W";

            }else if(LX == TX && LY > TY){

                str ="S";

            }else if(LX == TX && LY < TY){

                str ="N";

            }else 

            

            

            if(LX >  TX   && LY <  TY){//북동쪽.

                str="NE";

            }else if(LX >  TX   && LY >  TY){//남동쪽

                str="SE";

            }else if(LX <  TX   && LY >  TY){//남서쪽

                str="SW";

            }else if(LX <  TX   && LY <  TY){//북서쪽

                str="NW";

            }

            

            System.err.println("출발지 X   :"+ TX);

            System.err.println("출발지 Y   :"+ TY);

       

            // Write an action using System.out.println()

            // To debug: System.err.println("Debug messages...");


            System.out.println(str); // A single line providing the move to be made: N NE E SE S SW W or NW

            

               //동서남북.

            if(str.equals("E")){

                TX++;

            }else if(str.equals("W")){

                TX--;

            }else if(str.equals("S")){

                TY++;

            }else if(str.equals("N")){

                TY--;

            }else if(str.equals("NE")){

                TX++;

                TY--;

            }else if(str.equals("SE")){

                TX++;

                TY++;

            }else if(str.equals("SW")){

                TX--;

                TY++;

            }else if(str.equals("NW")){

                TX--;

                TY--;

            }

        }

    }

}

'GAME > www.codingame.com' 카테고리의 다른 글

Temperatures  (0) 2015.02.11
Skynet: the Chasm  (0) 2015.02.10
The Descent  (0) 2015.02.09
OnBoarding  (0) 2015.02.09