結果

問題 No.346 チワワ数え上げ問題
ユーザー 37zigen37zigen
提出日時 2016-04-11 19:38:15
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 450 bytes
コンパイル時間 2,375 ms
コンパイル使用メモリ 74,420 KB
実行使用メモリ 54,704 KB
最終ジャッジ日時 2024-04-15 00:18:14
合計ジャッジ時間 7,066 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
54,000 KB
testcase_01 AC 119 ms
53,064 KB
testcase_02 AC 126 ms
54,152 KB
testcase_03 AC 128 ms
54,016 KB
testcase_04 AC 129 ms
54,104 KB
testcase_05 AC 127 ms
54,000 KB
testcase_06 AC 127 ms
54,144 KB
testcase_07 AC 128 ms
54,048 KB
testcase_08 AC 132 ms
54,256 KB
testcase_09 AC 130 ms
54,360 KB
testcase_10 AC 188 ms
54,452 KB
testcase_11 AC 186 ms
54,488 KB
testcase_12 AC 189 ms
54,632 KB
testcase_13 AC 184 ms
54,396 KB
testcase_14 AC 130 ms
53,264 KB
testcase_15 AC 196 ms
54,412 KB
testcase_16 AC 197 ms
54,504 KB
testcase_17 AC 199 ms
54,596 KB
testcase_18 AC 196 ms
54,428 KB
testcase_19 AC 192 ms
54,704 KB
testcase_20 AC 194 ms
54,480 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 126 ms
53,988 KB
testcase_24 AC 128 ms
54,324 KB
testcase_25 AC 128 ms
54,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
		int 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(int n){
		return (n*(n-1))/2;
	}
}
0