結果

問題 No.559 swapAB列
ユーザー motimoti
提出日時 2018-05-20 08:33:47
言語 Perl
(5.38.2)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 253 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 5,092 KB
最終ジャッジ日時 2023-09-10 23:53:45
合計ジャッジ時間 828 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,016 KB
testcase_01 AC 5 ms
5,092 KB
testcase_02 AC 5 ms
5,092 KB
testcase_03 AC 5 ms
5,016 KB
testcase_04 AC 5 ms
4,984 KB
testcase_05 AC 5 ms
5,012 KB
testcase_06 AC 5 ms
5,068 KB
testcase_07 AC 5 ms
5,032 KB
testcase_08 AC 5 ms
4,956 KB
testcase_09 AC 5 ms
4,820 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/env perl

use strict;
use warnings;

my $in = <>; chomp $in;
my @vs = (split //,$in);
my $countA = 0;
my $res = 0;
while (my ($index, $c) = each(@vs)) {
  if ($c eq 'A') {
    $res += $index - $countA;
    $countA++;
  }
}
print $res . "\n";
0