結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー itezpaceitezpace
提出日時 2016-11-03 08:23:23
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,913 bytes
コンパイル時間 4,183 ms
コンパイル使用メモリ 79,328 KB
実行使用メモリ 73,112 KB
最終ジャッジ日時 2023-08-16 13:19:04
合計ジャッジ時間 16,616 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.math.BigDecimal;

public class Yuki229{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = lcm(a, lcm(b, c));
    double a2 = a;
    a2 /= 2;
    double b2 = b;
    b2 /= 2;
    double c2 = c;
    c2 /= 2;
    int d3 = 1;
    double e = 1;
    double a2_2 = 1;
    a2_2 /= a2;
    double b2_2 = 1;
    b2_2 /= b2;
    double c2_2 = 1;
    c2_2 /= c2;
    for(int i=1; i <= d; i++){
      double d2 = d;
      d2 /= i;
      double a3 = d2;
      a3 *= a2_2;
      double b3 = d2;
      b3 *= b2_2;
      double c3 = d2;
      c3 *= c2_2;
      double a4 = 0, b4 = 0, c4 = 0;
      int a3_2 = (int)a3;
      if(a3_2 % 2 == 0){
        a4 = a3 - a3_2;
      } else {
        a4 = 1 - (a3 - a3_2);
      }
      int b3_2 = (int)b3;
      if(b3_2 % 2 == 0){
        b4 = b3 - b3_2;
      } else {
        b4 = 1 - (b3 - b3_2);
      }
      int c3_2 = (int)c3;
      if(c3_2 % 2 == 0){
        c4 = c3 - c3_2;
      } else {
        c4 = 1 - (c3 - c3_2);
      }
      BigDecimal bd_a4 = new BigDecimal(a4);
      BigDecimal bd_a5 = bd_a4.setScale(10, BigDecimal.ROUND_HALF_UP);
      BigDecimal bd_b4 = new BigDecimal(b4);
      BigDecimal bd_b5 = bd_b4.setScale(10, BigDecimal.ROUND_HALF_UP);
      BigDecimal bd_c4 = new BigDecimal(c4);
      BigDecimal bd_c5 = bd_c4.setScale(10, BigDecimal.ROUND_HALF_UP);
      double a6 = bd_a5.doubleValue();
      double b6 = bd_b5.doubleValue();
      double c6 = bd_c5.doubleValue();
      if(a6 == b6 && b6 == c6){
        d3=i;
      }
    }
    System.out.println(d + "/" + d3);
  }

  public static int gcd(int a, int b){
    int c;
    if(b!=0){
      c=gcd(b, a % b);
    } else {
      c=a;
    }
    return c;
  }

  public static int lcm(int a, int b){
    int c = a * b / gcd(a, b);
    return c;
  }
}
0