結果

問題 No.1794 Continued Fraction
ユーザー tentententen
提出日時 2023-08-08 09:10:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,785 bytes
コンパイル時間 2,852 ms
コンパイル使用メモリ 85,220 KB
実行使用メモリ 52,916 KB
最終ジャッジ日時 2024-04-26 02:29:19
合計ジャッジ時間 6,159 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
50,680 KB
testcase_01 AC 65 ms
51,192 KB
testcase_02 AC 68 ms
50,896 KB
testcase_03 AC 60 ms
50,428 KB
testcase_04 AC 62 ms
51,256 KB
testcase_05 AC 64 ms
50,904 KB
testcase_06 AC 65 ms
50,828 KB
testcase_07 AC 63 ms
50,620 KB
testcase_08 AC 65 ms
51,048 KB
testcase_09 AC 63 ms
50,764 KB
testcase_10 AC 65 ms
51,116 KB
testcase_11 AC 62 ms
50,928 KB
testcase_12 AC 62 ms
51,176 KB
testcase_13 AC 59 ms
50,424 KB
testcase_14 AC 59 ms
50,796 KB
testcase_15 AC 60 ms
51,012 KB
testcase_16 AC 58 ms
50,940 KB
testcase_17 AC 58 ms
51,008 KB
testcase_18 AC 61 ms
51,196 KB
testcase_19 AC 57 ms
50,980 KB
testcase_20 AC 63 ms
51,044 KB
testcase_21 AC 60 ms
52,916 KB
testcase_22 AC 58 ms
51,032 KB
testcase_23 AC 66 ms
51,060 KB
testcase_24 AC 63 ms
51,020 KB
testcase_25 AC 62 ms
50,988 KB
testcase_26 AC 59 ms
50,824 KB
testcase_27 AC 63 ms
51,048 KB
testcase_28 AC 63 ms
50,972 KB
testcase_29 AC 62 ms
50,672 KB
testcase_30 AC 59 ms
50,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    static int ans = 0;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        ArrayList<Integer> ans = new ArrayList<>();
        while (b > 0) {
            ans.add(a / b);
            int mod = a % b;
            a = b;
            b = mod;
        }
        System.out.println(ans.stream().map(x -> x.toString()).collect(Collectors.joining(" ")));
    }
    
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0