ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1000. A+B Problem

No subject
Posted by Bart11 22 Apr 2018 18:51
import java.util.Scanner;


public class task9 {


    public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int n = sc.nextInt();
          int m = sc.nextInt();
          int x = sc.nextInt();
          int y = sc.nextInt();
          int cl = 0;
          int stroka =1;
          int[][] mas = new int[n][m];
         for(int i=0;i<n;i++){
             if(stroka%2==1){
                 for(int j=0;j<m;j++){
                 mas[i][j]=cl;
                 cl++;

                 }
                 stroka++;
             }
             else{
                 for(int j=m-1;j>=0;j--){
                 mas[i][j]=cl;
                 cl++;
                 }
                 stroka++;
             }
         }
        System.out.println(mas[x-1][y-1]);

            }


}
Re: No subject
Posted by Jetlog 7 May 2019 14:29
¼script¾alert(¢1¢)¼/script¾


Edited by author 07.05.2019 14:29

Edited by author 07.05.2019 14:36