結果

問題 No.559 swapAB列
ユーザー Pump0129Pump0129
提出日時 2018-03-26 11:51:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 1,828 ms
コンパイル使用メモリ 71,608 KB
実行使用メモリ 56,084 KB
最終ジャッジ日時 2023-09-07 12:39:39
合計ジャッジ時間 3,828 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,828 KB
testcase_01 AC 118 ms
55,692 KB
testcase_02 AC 117 ms
55,692 KB
testcase_03 AC 115 ms
56,000 KB
testcase_04 AC 117 ms
55,952 KB
testcase_05 AC 118 ms
56,084 KB
testcase_06 AC 116 ms
55,928 KB
testcase_07 AC 117 ms
56,076 KB
testcase_08 AC 118 ms
55,900 KB
testcase_09 AC 117 ms
55,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package net.ipipip0129.yukicoder.no559;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String line = scan.nextLine();
		
		scan.close();
		
		int acnt = 0;
		int swapcnt = 0;
		
		for (int i = line.length() - 1; 0 <= i; i--) {
			switch (line.charAt(i)) {
			case 'A':
				acnt++;
				break;
			case 'B':
				swapcnt += acnt;
				break;
			}
		}
		
		System.out.println(swapcnt);
	}
}
0