結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
![]() |
提出日時 | 2017-05-14 21:46:03 |
言語 | PHP (843.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 392 bytes |
コンパイル時間 | 94 ms |
コンパイル使用メモリ | 30,920 KB |
実行使用メモリ | 36,316 KB |
最終ジャッジ日時 | 2024-09-16 05:51:59 |
合計ジャッジ時間 | 4,620 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 10 TLE * 1 -- * 12 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?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; }