結果
| 問題 | 
                            No.346 チワワ数え上げ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             n120aosssssssss
                         | 
                    
| 提出日時 | 2017-05-14 22:12:29 | 
| 言語 | PHP  (843.2)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 43 ms / 2,000 ms | 
| コード長 | 533 bytes | 
| コンパイル時間 | 298 ms | 
| コンパイル使用メモリ | 32,276 KB | 
| 実行使用メモリ | 32,532 KB | 
| 最終ジャッジ日時 | 2024-09-16 05:52:26 | 
| 合計ジャッジ時間 | 2,377 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 | 
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php
 $string = trim(fgets(STDIN));
 //文字数
 $length = strlen($string);
 //指定開始位置からwの数
 $allwCnt = countW($string, $length);
 //チワワの数
 $cwCnt = 0;
 for($i = 0; $i < $length; $i++) {
 	if($string[$i] === 'c') {
 		$cwCnt += $allwCnt * ($allwCnt - 1) / 2;
 	} else if($string[$i] === 'w') {
 		$allwCnt--;
 	}
 }
 echo $cwCnt;
 echo PHP_EOL;
 
 function countW($string, $length) {
 	$wCnt = 0;
 	for($i = 0; $i < $length; $i++) {
 		if($string[$i] === 'w') {
 			$wCnt++;
 		}
 	}
 	return $wCnt;
 }
            
            
            
        
            
n120aosssssssss