結果

問題 No.346 チワワ数え上げ問題
ユーザー n120aosssssssssn120aosssssssss
提出日時 2017-05-14 21:46:03
言語 PHP
(8.2.11)
結果
TLE  
実行時間 -
コード長 392 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 12,072 KB
実行使用メモリ 24,548 KB
最終ジャッジ日時 2023-10-14 10:59:32
合計ジャッジ時間 4,609 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
24,548 KB
testcase_01 AC 7 ms
12,204 KB
testcase_02 AC 7 ms
12,232 KB
testcase_03 AC 8 ms
12,308 KB
testcase_04 AC 7 ms
12,240 KB
testcase_05 AC 7 ms
12,220 KB
testcase_06 AC 8 ms
12,320 KB
testcase_07 AC 7 ms
12,204 KB
testcase_08 AC 8 ms
12,180 KB
testcase_09 AC 7 ms
12,200 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?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