結果

問題 No.346 チワワ数え上げ問題
ユーザー 37zigen
提出日時 2016-04-11 19:42:35
言語 Java
(openjdk 23)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 2,515 ms
コンパイル使用メモリ 77,716 KB
実行使用メモリ 54,772 KB
最終ジャッジ日時 2024-10-04 06:34:43
合計ジャッジ時間 6,281 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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