結果

問題 No.559 swapAB列
ユーザー tetsutetsu
提出日時 2017-08-25 22:29:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 397 bytes
コンパイル時間 3,147 ms
コンパイル使用メモリ 72,444 KB
実行使用メモリ 55,900 KB
最終ジャッジ日時 2023-08-05 18:50:28
合計ジャッジ時間 5,460 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,752 KB
testcase_01 AC 122 ms
55,736 KB
testcase_02 AC 122 ms
55,284 KB
testcase_03 AC 118 ms
55,900 KB
testcase_04 AC 123 ms
55,584 KB
testcase_05 AC 123 ms
55,336 KB
testcase_06 AC 123 ms
55,348 KB
testcase_07 AC 125 ms
55,196 KB
testcase_08 AC 123 ms
55,540 KB
testcase_09 AC 125 ms
55,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yuki172;

import java.util.Scanner;

public class B {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		int bonus = 0;
		int ans = 0;
		for(int i=0; i<S.length(); i++) {
			if(S.charAt(i) == 'A') {
				ans += bonus;
			} else {
				bonus++;
			}
		}
		System.out.println(ans);
	}
}
0