結果

問題 No.1794 Continued Fraction
ユーザー tentententen
提出日時 2021-12-24 09:13:45
言語 Java19
(openjdk 21)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 1,336 bytes
コンパイル時間 3,185 ms
コンパイル使用メモリ 78,744 KB
実行使用メモリ 53,540 KB
最終ジャッジ日時 2023-10-19 09:58:44
合計ジャッジ時間 7,113 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,512 KB
testcase_01 AC 56 ms
52,516 KB
testcase_02 AC 56 ms
53,512 KB
testcase_03 AC 55 ms
53,524 KB
testcase_04 AC 56 ms
53,524 KB
testcase_05 AC 56 ms
53,524 KB
testcase_06 AC 55 ms
53,524 KB
testcase_07 AC 54 ms
53,512 KB
testcase_08 AC 55 ms
53,540 KB
testcase_09 AC 57 ms
53,512 KB
testcase_10 AC 56 ms
53,524 KB
testcase_11 AC 55 ms
53,524 KB
testcase_12 AC 56 ms
53,520 KB
testcase_13 AC 54 ms
51,468 KB
testcase_14 AC 55 ms
53,516 KB
testcase_15 AC 56 ms
53,520 KB
testcase_16 AC 55 ms
53,512 KB
testcase_17 AC 55 ms
53,520 KB
testcase_18 AC 56 ms
53,524 KB
testcase_19 AC 55 ms
53,524 KB
testcase_20 AC 57 ms
53,512 KB
testcase_21 AC 55 ms
51,476 KB
testcase_22 AC 56 ms
53,524 KB
testcase_23 AC 57 ms
53,520 KB
testcase_24 AC 56 ms
52,484 KB
testcase_25 AC 56 ms
53,512 KB
testcase_26 AC 57 ms
53,512 KB
testcase_27 AC 56 ms
51,560 KB
testcase_28 AC 55 ms
53,520 KB
testcase_29 AC 55 ms
52,524 KB
testcase_30 AC 55 ms
53,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<Integer> ans = new ArrayList<>();
        while (m > 0) {
            ans.add(n / m);
            int mod = n % m;
            n = m;
            m = mod;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < ans.size(); i++) {
            if (i > 0) {
                sb.append(" ");
            }
            sb.append(ans.get(i));
        }
        System.out.println(sb);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    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 String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0