發表文章

UVA 11321 Java

import java.util.*; import static java.lang.System.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextInt()) { int num = sc.nextInt(); int m = sc.nextInt(); System.out.printf("%d %d\r\n", num, m); if(num == 0&& m == 0) break; Data[] datas = new Data[num]; for(int i = 0; i { int n; int r; boolean even; Data(int n, int r, boolean even) { this.n = n; this.r = r; this.even = even; } public String toString() { return Integer.toString(this.n); } @Override public int compareTo(Data other) { if(this.r != other.r) return this.r

UVA 118 Java

import java.util.*; import static java.lang.System.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int w = sc.nextInt(), h = sc.nextInt(); boolean drop_loc[][] = new boolean[51][51]; while(sc.hasNext()) { int x = sc.nextInt(), y = sc.nextInt(); char ori = sc.next().charAt(0); String cmd = sc.next(); boolean drop = false; for(int i = 0; i w || tempy > h) { if(!drop_loc[x][y]) { drop_loc[x][y] = true; drop = true; break; } } else { x = tempx; y = tempy; } } } if(drop) { System.out.printf("%d %d %c LOST\r\n", x, y, ori); } else System.out.printf("%d %d %c\r\n", x, y, ori); } } };

UVA 10415 Java

import java.util.*; import static java.lang.System.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int cases = sc.nextInt(); for(int t = 0; t

UVA 10409 Java

import java.util.*; import static java.lang.System.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextInt()) { int num = sc.nextInt(); if(num == 0) break; int top = 1, n = 2, w = 3, s = 5, e = 4; for(int i = 0; i

UVA 10189 Java

import java.util.*; import static java.lang.System.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t = 0, h = 0, w =0; while(sc.hasNextInt()) { h = sc.nextInt(); w = sc.nextInt(); if(h == 0 || w == 0) break; if(t != 0) System.out.println(); System.out.printf("Field #%d:\r\n", ++t); char[][] map = new char[h][w]; for(int i = 0; i = 0 && map[i - 1][j] == '*') count++; if( i + 1 = 0 && map[i][j - 1] == '*') count++; if( j + 1 = 0 && j - 1 >= 0 && map[i - 1][j - 1] == '*') count++; if( i - 1 >= 0 && j + 1 = 0 && map[i + 1][j - 1] == '*') count++; if( i + 1

UVA 10057 Java

import java.util.*; import static java.lang.System.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextInt()) { int n = sc.nextInt(); int[] datas = new int[n]; for(int i = 0; i

UVA 10242 Java

import java.util.*; import static java.lang.System.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextDouble()) { double[] px = new double[4]; double[] py = new double[4]; double x = 0, y = 0; for(int i = 0; i