結果

問題 No.1794 Continued Fraction
ユーザー tentententen
提出日時 2022-08-09 09:39:17
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,362 bytes
コンパイル時間 4,059 ms
コンパイル使用メモリ 78,164 KB
実行使用メモリ 54,216 KB
最終ジャッジ日時 2023-10-19 20:34:46
合計ジャッジ時間 7,351 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,372 KB
testcase_01 AC 56 ms
53,356 KB
testcase_02 AC 56 ms
53,360 KB
testcase_03 AC 55 ms
53,360 KB
testcase_04 AC 56 ms
53,356 KB
testcase_05 AC 55 ms
53,368 KB
testcase_06 AC 55 ms
53,352 KB
testcase_07 RE -
testcase_08 AC 55 ms
53,368 KB
testcase_09 AC 57 ms
53,368 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 59 ms
53,360 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 61 ms
53,356 KB
testcase_17 AC 55 ms
53,360 KB
testcase_18 RE -
testcase_19 AC 56 ms
53,368 KB
testcase_20 AC 55 ms
53,360 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 56 ms
53,356 KB
testcase_24 RE -
testcase_25 AC 56 ms
53,360 KB
testcase_26 AC 55 ms
53,368 KB
testcase_27 RE -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

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 (n > 1) {
            ans.add(n / m);
            int tmp = n % m;
            n = m;
            m = tmp;
        }
        //ans.add(n);
        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 {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0