zoukankan      html  css  js  c++  java
  • 牛客网-第一场-J-Fraction Comparision

    import java.math.BigInteger;
    import java.util.Scanner;
    
    public class Main {
    
    	public static void main(String[] args) {
    
    		Scanner in = new Scanner(System.in);
    
    		while (in.hasNext()) {
    			BigInteger x = in.nextBigInteger();
    			BigInteger a = in.nextBigInteger();
    			BigInteger y = in.nextBigInteger();
    			BigInteger b = in.nextBigInteger();
    			int re = x.multiply(b).compareTo(y.multiply(a));
    			if(re==-1)
    				System.out.println("<");
    			else if(re==1)
    				System.out.println(">");
    			else 
    				System.out.println("=");
    		}
    	}
    }
    

    数学计算

    import java.util.Scanner;
     
    public class Main{
     public static void main(String[] args) {
       
      Scanner in = new Scanner(System.in);
       
      while(in.hasNext()) {
        
       long x = in.nextLong();
       long a = in.nextLong();
       long y = in.nextLong();
       long b = in.nextLong();
        
       long x1 = x/a;
       long x2 = x%a;  //利用求余跟整数 得到答案
       long y1 = y/b;
       long y2 = y%b;
        
       long r1 = x2 * b;
       long r2 = y2 * a;
        
       if(x1 == y1 && r1 == r2)
        System.out.println("=");
       else if(x1 < y1 ||(x1 == y1 && r1 < r2)){
        System.out.println("<");
       }
       else {
        System.out.println(">");
       } 
      } 
     }
    }
    
  • 相关阅读:
    面向对象中一些容易混淆的概念
    day12作业
    day10作业
    day09作业
    Where与Having的区别
    排序算法之快速排序
    排序算法之冒泡排序
    jQuery中的100个技巧
    用node.js给图片加水印
    代码高亮美化插件-----SyntaxHighlighter
  • 原文地址:https://www.cnblogs.com/cznczai/p/11209274.html
Copyright © 2011-2022 走看看