結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
![]() |
提出日時 | 2016-06-02 16:55:27 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 462 bytes |
コンパイル時間 | 2,783 ms |
コンパイル使用メモリ | 74,260 KB |
実行使用メモリ | 42,480 KB |
最終ジャッジ日時 | 2024-10-08 05:32:30 |
合計ジャッジ時間 | 7,254 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 9 |
ソースコード
import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); System.out.println(solve(sc.next())); sc.close(); } public static int solve (String s) { int wcnt = 0, sum = 0; int len = s.length(); for (int i = len - 1; i >= 0; i--) { if (s.charAt(i) == 'w') { wcnt++; continue; } if (s.charAt(i) == 'c') sum += wcnt * (wcnt - 1) / 2; } return sum; } }