結果
問題 | No.1464 Number Conversion |
ユーザー | threepipes_s |
提出日時 | 2021-04-02 22:01:17 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 2,655 bytes |
コンパイル時間 | 2,308 ms |
コンパイル使用メモリ | 86,052 KB |
実行使用メモリ | 52,296 KB |
最終ジャッジ日時 | 2024-06-06 06:50:49 |
合計ジャッジ時間 | 5,466 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
50,500 KB |
testcase_01 | AC | 71 ms
51,052 KB |
testcase_02 | AC | 75 ms
50,932 KB |
testcase_03 | AC | 57 ms
50,548 KB |
testcase_04 | AC | 74 ms
50,844 KB |
testcase_05 | AC | 76 ms
51,280 KB |
testcase_06 | AC | 74 ms
51,460 KB |
testcase_07 | AC | 74 ms
50,824 KB |
testcase_08 | AC | 85 ms
51,448 KB |
testcase_09 | AC | 73 ms
51,220 KB |
testcase_10 | AC | 73 ms
51,312 KB |
testcase_11 | AC | 73 ms
50,992 KB |
testcase_12 | AC | 74 ms
51,208 KB |
testcase_13 | AC | 73 ms
51,200 KB |
testcase_14 | AC | 75 ms
50,868 KB |
testcase_15 | AC | 72 ms
51,052 KB |
testcase_16 | AC | 74 ms
51,460 KB |
testcase_17 | AC | 75 ms
51,048 KB |
testcase_18 | AC | 75 ms
51,036 KB |
testcase_19 | AC | 75 ms
51,040 KB |
testcase_20 | AC | 78 ms
51,492 KB |
testcase_21 | AC | 74 ms
51,116 KB |
testcase_22 | AC | 77 ms
51,228 KB |
testcase_23 | AC | 57 ms
50,484 KB |
testcase_24 | AC | 83 ms
51,124 KB |
testcase_25 | AC | 87 ms
52,296 KB |
testcase_26 | AC | 83 ms
51,184 KB |
testcase_27 | AC | 78 ms
51,168 KB |
testcase_28 | AC | 58 ms
50,240 KB |
ソースコード
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.Closeable; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class Main { static ContestScanner in;static Writer out;static StringBuilder sb=new StringBuilder(); public static void main(String[] args) {try{in=new ContestScanner();out=new Writer();Main solve=new Main();solve.solve(); in.close();out.flush();out.close();}catch(IOException e){e.printStackTrace();}} void solve() throws NumberFormatException, IOException{ String[] xStr = in.nextToken().split("\\."); if (xStr.length == 1) { System.out.println(xStr[0] + "/1"); return; } long diver = 1; for (int i = 0; i < xStr[1].length(); i++) { diver *= 10; } long upper = Long.parseLong(xStr[0] + xStr[1]); long g = gcd(diver, upper); diver /= g; upper /= g; System.out.println(upper + "/" + diver); } static long gcd(long a, long b){ return b == 0 ? a : gcd(b, a % b); } } class Writer extends PrintWriter{ public Writer(String filename)throws IOException {super(new BufferedWriter(new FileWriter(filename)));} public Writer()throws IOException{super(System.out);} } class ContestScanner implements Closeable{ private BufferedReader in;private int c=-2; public ContestScanner()throws IOException {in=new BufferedReader(new InputStreamReader(System.in));} public ContestScanner(String filename)throws IOException {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));} public String nextToken()throws IOException { StringBuilder sb=new StringBuilder(); while((c=in.read())!=-1&&Character.isWhitespace(c)); while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();} return sb.toString(); } public String readLine()throws IOException{ StringBuilder sb=new StringBuilder();if(c==-2)c=in.read(); while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();} return sb.toString(); } public long nextLong()throws IOException,NumberFormatException {return Long.parseLong(nextToken());} public int nextInt()throws NumberFormatException,IOException {return(int)nextLong();} public double nextDouble()throws NumberFormatException,IOException {return Double.parseDouble(nextToken());} public void close() throws IOException {in.close();} }