結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
|
提出日時 | 2016-04-11 19:38:15 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 450 bytes |
コンパイル時間 | 1,784 ms |
コンパイル使用メモリ | 74,916 KB |
実行使用メモリ | 54,308 KB |
最終ジャッジ日時 | 2024-10-04 06:34:30 |
合計ジャッジ時間 | 6,559 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 2 |
ソースコード
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; } }