zoukankan      html  css  js  c++  java
  • 1024程序员节!(JAVA Code)

    点我:传送门 

    程序员节快乐~

    水水题

    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;
            }
        }
    }
    View Code

    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;
            }
        }
    }
    View Code

    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;
            }
        }
    }
    View Code


    思路:连续的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;
            }
        }
    }
    View Code

    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;
            }
        }
    }
    View Code
  • 相关阅读:
    Tomcat下使用war包发布项目
    shell编程报错:“syntax error near unexpected token `”
    undo表空间不足,ORA-30036: unable to extend segment by 8 in undo tablespace 'UNDOTBS2'
    HTML快速入门
    HTTP协议快速入门
    Java Web应用的开发模式
    使用Jekyll搭建免费的Github Pages个人博客
    前端模拟API数据的两种方式
    Node.js学习笔记
    socket.io笔记
  • 原文地址:https://www.cnblogs.com/Esquecer/p/11735013.html
Copyright © 2011-2022 走看看