結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
|
提出日時 | 2017-04-01 10:14:38 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 665 bytes |
コンパイル時間 | 2,906 ms |
コンパイル使用メモリ | 75,220 KB |
実行使用メモリ | 49,336 KB |
最終ジャッジ日時 | 2024-07-07 18:45:11 |
合計ジャッジ時間 | 14,118 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 13 WA * 7 TLE * 1 -- * 2 |
ソースコード
import java.util.Scanner; public class Chiwawa { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner s = new Scanner(System.in); StringBuilder str = new StringBuilder(s.nextLine()); s.close(); int all = 0; while(str.indexOf("c") != -1){ int t = str.indexOf("c"); int count = 0; for(int i = t;i < str.length();i++){ if(str.charAt(i) == 'w'){ count++; } } all += Combination(count,2); str.deleteCharAt(t); } System.out.println(all); } static int Combination(int r,int q){ int rCq = 1; for(int i = 1;i <= q;i++){ rCq = rCq * r-- / i; } return rCq; } }