結果

問題 No.346 チワワ数え上げ問題
コンテスト
ユーザー n120aosssssssss
提出日時 2017-05-14 21:46:03
言語 PHP
(8.5.4)
コンパイル:
php -l _filename_
実行:
php _filename_
結果
TLE  
実行時間 -
コード長 392 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 38 ms
コンパイル使用メモリ 37,008 KB
実行使用メモリ 38,620 KB
最終ジャッジ日時 2026-08-28 13:22:29
合計ジャッジ時間 20,319 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 17 TLE * 4 -- * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #
raw source code

<?php
 $string = trim(fgets(STDIN));
 $length = strlen($string);
 $cnt = 0;
 for($i = 0; $i < $length; $i++) {
 	if($string[$i] === 'c') {
 		$cnt += nC2($string, $i + 1, $length);
 	}
 }
 echo $cnt;
 echo PHP_EOL;
 
 function nC2($string, $s, $length) {
 	$wCnt = 0;
 	for($i = $s; $i < $length; $i++) {
 		if($string[$i] === 'w') {
 			$wCnt++;
 		}
 	}
 	return $wCnt * ($wCnt - 1) / 2;
 }
0