發表文章

目前顯示的是 10月, 2020的文章

UVA 11349 Java

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

UVA 10812 Java

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

UVA 10170 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()) { long p = sc.nextLong(); long d = sc.nextLong(); long s = p; while(s

UVA 10056 Java

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

UVA 12019 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[] mon = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int cases = sc.nextInt(); for(int i =0; i

UVA 10252 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextLine()) { String str1 = sc.nextLine().toLowerCase(); String str2 = sc.nextLine().toLowerCase(); int[] count1 = new int[26]; int[] count2 = new int[26]; for(int i = 0; i ='a' && c = 'a' && c

UVA 100 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextInt()) { int num1 = sc.nextInt(); int num2 = sc.nextInt(); int max_n = Math.max(num1, num2); int min_n = Math.min(num1, num2); int max = 0; for(int i = min_n; i max) max = count; } System.out.printf("%d %d %d\r\n", num1, num2, max); } } };

UVA 11063 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int cases = 0; while(sc.hasNextInt()) { int input = sc.nextInt(); if(input >= 2 && input sum = new ArrayList (); for(int i = 0; i

UVA 10101 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int count = 0; while(sc.hasNextLong()) { long num = sc.nextLong(); System.out.printf("%4d.", ++count); if(num == 0) System.out.print(" 0"); else bangla(num); System.out.println(); } } public static void bangla(long num) { if(num >= 10000000) { bangla(num / 10000000); System.out.print(" kuti"); num = num % 10000000; } if(num >= 100000) { bangla(num / 100000); System.out.print(" lakh"); num = num % 100000; } if(num >= 1000) { bangla(num / 1000); System.out.print(" hajar"); num = num % 1000; } if(num >= 100) { bangla(num / 100); System.out.print(" shata"); num = num % 100; } if(num > 0) System.out...

UVA 272 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); boolean check = true; while(sc.hasNextLine()) { String str = sc.nextLine(); for(int i=0; i

UVA 11332 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextLine()) { String str = sc.nextLine(); if(str.equals("0")) break; while(str.length() > 1) { int num = 0; for(int i = 0; i import java.util.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextLine()) { int num = Integer.parseInt(sc.nextLine()); if(num == 0) break; while(num >= 10) { int temp = 0; while(num != 0) { temp += num % 10; num /= 10; } num = temp; } System.out.println(num); } } };

UVA 490 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 max = 0; List inputs = new ArrayList (); while(sc.hasNextLine()) { String str = sc.nextLine(); if(str.length() > max) max = str.length(); inputs.add(str); } Collections.reverse(inputs); for(int j = 0; j 0) { System.out.print(" "); count--; } System.out.print(str.charAt(j)); count = 0; } else count++; } System.out.println(); } } };

UVA 10019 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 lines = sc.nextInt(); for(int i =0; i

UVA 10035 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 num1 = sc.nextInt(); int num2 = sc.nextInt(); if(num1 == 0 && num2 ==0) break; else { int count = 0; int temp = 0; while(num1 != 0 || num2 !=0) { int n1 = num1 % 10; int n2 = num2 % 10; temp = temp + n1 + n2; if(temp >= 10) count ++; temp /= 10; num1 /= 10; num2 /= 10; } if(count == 0) System.out.println("No carry operation."); else if(count == 1) System.out.println("1 carry operation."); else System.out.println(String.format("%d carry operations.", count)); } } } };

UVA 10008 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int lines = sc.nextInt(); sc.nextLine(); int[] count = new int[26]; int max = 0; for(int i = 0; i = 97 && ch max) max = count[ch - 97]; } } for(int i = max; i > 0; i--) for(int j = 0; j

UVA 10420 Java

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

UVA 10222 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); String decode = "qwertyuiop[]asdfghjkl;'zxcvbnm,./"; while(sc.hasNextLine()) { String str = sc.nextLine().toLowerCase(); for(int i = 0; i

UVA 10038 Java

import static java.lang.System.*; public class main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextInt()) { int size = sc.nextInt(); boolean is_jolly = true; if(size != 1) { int[] input = new int[size]; for(int i = 0; i

UVA 11150 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(); System.out.println(n + n / 2); } } };

UVA 10783 Java

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

UVA 10268 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNextLine()) { int x = Integer.parseInt(sc.nextLine()); String[] str = sc.nextLine().split(" "); //System.out.println(x); int output = 0; for(int i = 0; i

UVA 10929 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNextLine()) { String str = sc.nextLine(); if(str.equals("0")) return; int odd=0, even=0; for(int i = 0; i

UVA 10055 Java

import java.util.*; public class main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()) { long n1 = sc.nextLong(); long n2 = sc.nextLong(); System.out.println(Math.abs(n1 - n2)); } } };

UVA 10041 Java

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