結果

問題 No.559 swapAB列
ユーザー tetsutetsu
提出日時 2017-08-25 22:29:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 397 bytes
コンパイル時間 3,580 ms
コンパイル使用メモリ 74,264 KB
実行使用メモリ 54,248 KB
最終ジャッジ日時 2024-04-23 15:33:25
合計ジャッジ時間 4,487 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
53,124 KB
testcase_01 AC 108 ms
53,700 KB
testcase_02 AC 105 ms
53,044 KB
testcase_03 AC 102 ms
53,072 KB
testcase_04 AC 107 ms
54,248 KB
testcase_05 AC 110 ms
53,928 KB
testcase_06 AC 103 ms
53,508 KB
testcase_07 AC 111 ms
53,628 KB
testcase_08 AC 110 ms
53,600 KB
testcase_09 AC 111 ms
53,868 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