結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2016-02-27 01:11:49 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 77 ms / 2,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 3,482 ms |
コンパイル使用メモリ | 75,092 KB |
実行使用メモリ | 51,268 KB |
最終ジャッジ日時 | 2024-09-24 10:55:25 |
合計ジャッジ時間 | 5,573 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class QuestionB { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line; try{ line = in.readLine(); }catch(IOException e){ System.out.println("0"); return; } long result = 0; long wcount = 0; for(int i = line.length() - 1; i >= 0; i--){ char k = line.charAt(i); if(k == 'c') result += wcount * (wcount - 1)/2; if(k == 'w') wcount++; } System.out.println(result); } }