結果

問題 No.346 チワワ数え上げ問題
コンテスト
ユーザー ねず
提出日時 2018-01-27 07:11:05
言語 PHP
(8.5.4)
コンパイル:
php -l _filename_
実行:
php _filename_
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 223 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 328 ms
コンパイル使用メモリ 36,656 KB
実行使用メモリ 37,032 KB
最終ジャッジ日時 2026-06-02 14:32:56
合計ジャッジ時間 2,292 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #
raw source code

<?php
$s = trim(fgets(STDIN));
$cntW = 0;
$ans = 0;
for ($i = strlen($s) - 1; $i >= 0; $i--) {
	if ($s[$i] == 'w') {
		$cntW++;
		continue;
	} else if ($s[$i] == 'c') {
		$ans += $cntW * ($cntW - 1) / 2;
	}
}
print $ans;
?>
0