結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2016-05-15 02:37:08 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 3,012 ms |
コンパイル使用メモリ | 74,672 KB |
実行使用メモリ | 51,436 KB |
最終ジャッジ日時 | 2024-10-06 03:07:32 |
合計ジャッジ時間 | 5,186 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Test346 { public static void main(String[] args) { long result = 0; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { long count_w = 0; String str = br.readLine(); char[] ch = str.toCharArray(); for(int i=ch.length-1;i>=0;i--){ if(ch[i]=='w'){ count_w++; }else if(ch[i]=='c'){ if(count_w >= 2){ result += count_w * (count_w - 1) / 2 ; } } } System.out.println(result); } catch (IOException e) { e.printStackTrace(); } } }