結果

問題 No.559 swapAB列
ユーザー samplelpmas
提出日時 2017-09-02 07:54:44
言語 Java
(openjdk 23)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 2,093 ms
コンパイル使用メモリ 74,812 KB
実行使用メモリ 54,500 KB
最終ジャッジ日時 2024-11-06 18:20:34
合計ジャッジ時間 4,133 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        char[] S = sc.next().toCharArray();

        int aCount = 0;
        int numSwap = 0;

        for (int i = 0; i < S.length; i++) {

            if (S[i] == 'A') {

                numSwap += i - aCount;
                aCount++;

            }

        }

        System.out.println(numSwap);

    }

}
0