結果
問題 | No.559 swapAB列 |
ユーザー |
![]() |
提出日時 | 2017-09-23 17:01:02 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 120 ms / 2,000 ms |
コード長 | 380 bytes |
コンパイル時間 | 1,933 ms |
コンパイル使用メモリ | 74,528 KB |
実行使用メモリ | 54,180 KB |
最終ジャッジ日時 | 2024-11-14 04:13:54 |
合計ジャッジ時間 | 3,874 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int n = 0; int sum = 0; for(int i = 0; i < s.length(); i++) { if(s.charAt(i) == 'A') { n++; sum += i; } } int ans = sum - (n * (n - 1)) / 2; System.out.println(ans); } }