結果

問題 No.346 チワワ数え上げ問題
ユーザー tentententen
提出日時 2022-07-30 16:16:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 1,188 bytes
コンパイル時間 3,228 ms
コンパイル使用メモリ 72,828 KB
実行使用メモリ 52,536 KB
最終ジャッジ日時 2023-09-27 18:39:52
合計ジャッジ時間 6,579 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,288 KB
testcase_01 AC 47 ms
49,144 KB
testcase_02 AC 45 ms
49,240 KB
testcase_03 AC 46 ms
49,284 KB
testcase_04 AC 45 ms
49,800 KB
testcase_05 AC 44 ms
49,632 KB
testcase_06 AC 45 ms
49,252 KB
testcase_07 AC 47 ms
49,340 KB
testcase_08 AC 47 ms
49,444 KB
testcase_09 AC 46 ms
49,240 KB
testcase_10 AC 79 ms
52,168 KB
testcase_11 AC 77 ms
51,172 KB
testcase_12 AC 77 ms
51,908 KB
testcase_13 AC 73 ms
51,008 KB
testcase_14 AC 48 ms
47,700 KB
testcase_15 AC 76 ms
52,432 KB
testcase_16 AC 77 ms
52,128 KB
testcase_17 AC 78 ms
52,196 KB
testcase_18 AC 79 ms
52,164 KB
testcase_19 AC 79 ms
52,008 KB
testcase_20 AC 78 ms
50,672 KB
testcase_21 AC 78 ms
52,236 KB
testcase_22 AC 80 ms
52,536 KB
testcase_23 AC 46 ms
47,360 KB
testcase_24 AC 45 ms
49,192 KB
testcase_25 AC 44 ms
49,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long cCount = 0;
        long w1Count = 0;
        long ans = 0;
        for (char c : sc.next().toCharArray()) {
            if (c == 'w') {
                ans += w1Count;
                w1Count += cCount;
            } else if (c == 'c') {
                cCount++;
            }
        }
        System.out.println(ans);
    }
}
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