結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
|
提出日時 | 2017-04-01 10:19:10 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 714 bytes |
コンパイル時間 | 2,869 ms |
コンパイル使用メモリ | 74,768 KB |
実行使用メモリ | 49,256 KB |
最終ジャッジ日時 | 2024-07-07 18:45:27 |
合計ジャッジ時間 | 13,925 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 21 TLE * 1 -- * 1 |
ソースコード
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(); long all = 0; while(str.indexOf("c") != -1){ int t = str.indexOf("c"); int count = 0; if(str.lastIndexOf("w") < t){ break; } 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; } }