結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
41,288 KB
testcase_01 AC 113 ms
41,484 KB
testcase_02 AC 97 ms
41,156 KB
testcase_03 AC 106 ms
41,308 KB
testcase_04 AC 112 ms
41,420 KB
testcase_05 AC 92 ms
40,948 KB
testcase_06 AC 108 ms
39,824 KB
testcase_07 AC 97 ms
41,448 KB
testcase_08 AC 124 ms
41,324 KB
testcase_09 AC 115 ms
41,096 KB
testcase_10 AC 174 ms
42,204 KB
testcase_11 AC 169 ms
41,728 KB
testcase_12 AC 168 ms
41,992 KB
testcase_13 AC 147 ms
41,532 KB
testcase_14 AC 141 ms
41,140 KB
testcase_15 AC 180 ms
42,268 KB
testcase_16 AC 173 ms
41,800 KB
testcase_17 AC 167 ms
42,092 KB
testcase_18 AC 186 ms
41,952 KB
testcase_19 AC 188 ms
42,580 KB
testcase_20 AC 170 ms
42,232 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 109 ms
41,068 KB
testcase_24 AC 108 ms
41,004 KB
testcase_25 AC 99 ms
41,180 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