結果

問題 No.279 木の数え上げ
ユーザー Lo_OTLo_OT
提出日時 2018-03-22 22:03:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,353 bytes
コンパイル時間 2,269 ms
コンパイル使用メモリ 73,820 KB
実行使用メモリ 66,276 KB
最終ジャッジ日時 2023-09-07 01:50:37
合計ジャッジ時間 8,265 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 120 ms
55,616 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 MLE -
testcase_13 WA -
testcase_14 WA -
testcase_15 MLE -
testcase_16 WA -
testcase_17 MLE -
testcase_18 WA -
testcase_19 MLE -
testcase_20 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        codeabbey solver = new codeabbey();
        solver.solve(1, in, out);
        out.close();
    }

    static class codeabbey {
        private static int gcd(int a, int b) {
            return b == 0 ? a : gcd(b, a % b);
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int t = 0, r = 0, e = 0;
            String str = in.nextLine(); // 10^6

            for (char ch : str.toCharArray()) {
                if (ch == 't') t++;
                if (ch == 'r') r++;
                if (ch == 'e') e++;
            }
//        System.out.println("t:" + t + " ,r:" + r + " ,e:" + e);
            if (e < 2) {
                out.println(0);
            } else {
                e = e / 2;
                int ans = gcd(t, r);
                ans = gcd(ans, e);
                out.println(ans);
            }
        }
    }
}

0