結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-26 23:20:42 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 551 bytes |
| 記録 | |
| コンパイル時間 | 404 ms |
| コンパイル使用メモリ | 89,824 KB |
| 実行使用メモリ | 11,300 KB |
| 最終ジャッジ日時 | 2026-04-11 06:01:40 |
| 合計ジャッジ時間 | 6,570 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 1 WA * 4 RE * 3 TLE * 1 -- * 14 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:20:22: warning: 'w' may be used uninitialized [-Wmaybe-uninitialized]
20 | if (c=='w') w+=1;
| ~^~~
main.cpp:14:11: note: 'w' was declared here
14 | int i,w,j,n;
| ^
ソースコード
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int fact(int n){int i,j;for(i=1,j=1;i<n;j*=i)i++;return j;}
int combi(int x,int k){return fact(x)/(fact(k)*fact(x-k));}
int main(){
char c;
int i,w,j,n;
int s[100005];
i=0;
while(cin>>c){
s[i++]=c;
if (c=='w') w+=1;
}
n=0;
for (j=0;j<i;j++){
if (w<=1) break;
if (s[j]=='c') n+=combi(w,2);
if (s[j]=='w') w-=1;
}
cout<<n<<endl;
return 0;
}