点我:传送门
程序员节快乐~
水水题
A
import java.util.*; import java.io.*; public class Main { public static void main (String[] argv) { new Main(); } boolean test = false; public Main(){ FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in))); //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in"))); Scanner input = new Scanner(System.in); while(input.hasNext()){ int n = input.nextInt(); int k = input.nextInt(); int countHurt = 0; for(int i = 0 ; i < n ; i ++) { double height = input.nextDouble(); if(height > 1.8) { double hurt = (height-1.8)*(10.24); countHurt += (int)hurt; } } if(countHurt >= k) { System.out.println("YES"); }else { System.out.println("NO"); } } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(BufferedReader in) { br = in; } String next() { while (st == null || !st.hasMoreElements()) { try { String line = br.readLine(); if (line == null || line.length() == 0) return ""; st = new StringTokenizer(line); } catch (IOException e) { return ""; //e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { return ""; //e.printStackTrace(); } return str; } } }
B
import java.util.*; import java.io.*; public class Main { public static void main (String[] argv) { new Main(); } boolean test = false; public Main(){ FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in))); //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in"))); Scanner input = new Scanner(System.in); while(input.hasNext()) { int n = input.nextInt(); String maxPowerMonkey = null; String minPowerMonkey = null; int maxPower = -1; int minPower = 1000000; while(n-->0){ String s = input.next(); int power = input.nextInt(); if(power > maxPower) { maxPower = power; minPowerMonkey = s; } if(power < minPower) { minPower = power; maxPowerMonkey= s; } } System.out.println(maxPowerMonkey + " "+ minPowerMonkey); } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(BufferedReader in) { br = in; } String next() { while (st == null || !st.hasMoreElements()) { try { String line = br.readLine(); if (line == null || line.length() == 0) return ""; st = new StringTokenizer(line); } catch (IOException e) { return ""; //e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { return ""; //e.printStackTrace(); } return str; } } }
C
import java.util.*; import java.io.*; import java.math.BigDecimal; public class Main { public static void main (String[] argv) { new Main(); } boolean test = false; public Main(){ FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in))); //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in"))); Scanner input = new Scanner(System.in); while(input.hasNext()) { int inputnumber = input.nextInt(); while(inputnumber-- >0) { BigDecimal n = input.nextBigDecimal(); System.out.println(n.multiply(new BigDecimal("1024")).setScale(2,BigDecimal.ROUND_HALF_UP)); } } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(BufferedReader in) { br = in; } String next() { while (st == null || !st.hasMoreElements()) { try { String line = br.readLine(); if (line == null || line.length() == 0) return ""; st = new StringTokenizer(line); } catch (IOException e) { return ""; //e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { return ""; //e.printStackTrace(); } return str; } } }
D
思路:连续的0需要翻转2次,如果第1位是0,那么次数减去1。
import java.util.*; import java.io.*; import java.math.BigDecimal; public class Main { public static void main (String[] argv) { new Main(); } boolean test = false; public Main(){ FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in))); //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in"))); Scanner input = new Scanner(System.in); while(input.hasNext()) { int inputnumber = input.nextInt(); while(inputnumber-- >0) { int cnt = 0,flag = 0,subflag = 0; String s = input.next(); for(int i = 0 ; i < s.length(); i ++) { if(i == 0 && s.charAt(i) == '0') { subflag = 1; } if(s.charAt(i)=='0' && flag == 0) { flag = 1; cnt ++; } if(s.charAt(i) == '1' && flag == 1) { flag = 0; } } System.out.println(cnt * 2 - subflag); } } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(BufferedReader in) { br = in; } String next() { while (st == null || !st.hasMoreElements()) { try { String line = br.readLine(); if (line == null || line.length() == 0) return ""; st = new StringTokenizer(line); } catch (IOException e) { return ""; //e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { return ""; //e.printStackTrace(); } return str; } } }
E
import java.util.*; import java.io.*; import java.math.BigDecimal; public class Main { int [] mapx = new int[1000100]; int [] mapy = new int[1000100]; public static void main (String[] argv) { new Main(); } boolean test = false; public Main(){ FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in))); //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in"))); int n = in.nextInt(); int m = in.nextInt(); for(int i = 1 ; i <= n ; i ++) { for(int j = 1 ; j <= m ; j++) { int number = in.nextInt(); mapx[number] = i; mapy[number] = j; } } int q = in.nextInt(); while(q-->0) { int queryNumber = in.nextInt(); System.out.println(mapx[queryNumber] + " "+mapy[queryNumber]); } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(BufferedReader in) { br = in; } String next() { while (st == null || !st.hasMoreElements()) { try { String line = br.readLine(); if (line == null || line.length() == 0) return ""; st = new StringTokenizer(line); } catch (IOException e) { return ""; //e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { return ""; //e.printStackTrace(); } return str; } } }