結果

問題 No.559 swapAB列
ユーザー GrenacheGrenache
提出日時 2017-08-25 22:23:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 4,292 ms
コンパイル使用メモリ 75,220 KB
実行使用メモリ 54,548 KB
最終ジャッジ日時 2024-04-23 15:30:09
合計ジャッジ時間 6,294 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
54,184 KB
testcase_01 AC 134 ms
54,124 KB
testcase_02 AC 132 ms
54,284 KB
testcase_03 AC 135 ms
54,324 KB
testcase_04 AC 133 ms
53,896 KB
testcase_05 AC 135 ms
54,548 KB
testcase_06 AC 135 ms
54,200 KB
testcase_07 AC 134 ms
54,024 KB
testcase_08 AC 136 ms
54,004 KB
testcase_09 AC 136 ms
53,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder559 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();
		int n = s.length;

		int ret = 0;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == 'A') {
				ret += i - cnt++;
			}
		}

		pr.println(ret);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0