結果

問題 No.346 チワワ数え上げ問題
ユーザー 37zigen37zigen
提出日時 2016-04-11 19:42:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 1,996 ms
コンパイル使用メモリ 74,844 KB
実行使用メモリ 54,692 KB
最終ジャッジ日時 2024-04-15 00:18:21
合計ジャッジ時間 7,106 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
53,772 KB
testcase_01 AC 132 ms
53,936 KB
testcase_02 AC 123 ms
54,104 KB
testcase_03 AC 130 ms
54,004 KB
testcase_04 AC 129 ms
54,040 KB
testcase_05 AC 129 ms
54,196 KB
testcase_06 AC 132 ms
54,004 KB
testcase_07 AC 132 ms
54,180 KB
testcase_08 AC 133 ms
54,016 KB
testcase_09 AC 129 ms
54,244 KB
testcase_10 AC 185 ms
54,512 KB
testcase_11 AC 175 ms
54,112 KB
testcase_12 AC 175 ms
54,360 KB
testcase_13 AC 177 ms
54,364 KB
testcase_14 AC 141 ms
54,224 KB
testcase_15 AC 182 ms
54,692 KB
testcase_16 AC 200 ms
54,284 KB
testcase_17 AC 184 ms
54,136 KB
testcase_18 AC 197 ms
54,416 KB
testcase_19 AC 194 ms
54,496 KB
testcase_20 AC 182 ms
54,400 KB
testcase_21 AC 200 ms
54,620 KB
testcase_22 AC 197 ms
54,632 KB
testcase_23 AC 129 ms
54,076 KB
testcase_24 AC 128 ms
54,304 KB
testcase_25 AC 133 ms
54,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;
import java.util.*;
public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		String str=sc.next();
		long m=0;
		long ans=0;
		for(int i=str.length()-1;i>=0;i--){
			if(str.charAt(i)=='w')m++;
			else if(str.charAt(i)=='c')ans+=combination(m);
		}
		System.out.println(ans);
		sc.close();
	}
	//nC2
	long combination(long n){
		return (n*(n-1))/2;
	}
}
0