結果

問題 No.457 (^^*)
ユーザー jjjj
提出日時 2016-12-08 23:26:18
言語 Fortran
(gFortran 13.2.0)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 27,100 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 02:37:21
合計ジャッジ時間 2,739 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 43 ms
4,376 KB
testcase_13 AC 101 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 60 ms
4,380 KB
testcase_16 AC 100 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  character*10000::S
  integer::numr=0,numr2,len
  integer::left=0,right=0
  integer::i,j,status
  read *,S
  len = LEN_TRIM(S)
  do i=1,len
     if(S(i:i)==')') then
        numr = numr + 1
     end if
  end do

  do i=1,len
     if(S(i:i)==')') then
        numr = numr - 1
        if(numr.eq.0) exit
        cycle
     else if(S(i:i)/='(') then
        cycle
     end if

     numr2 = numr
     status = 0
     do j=i+1,len
        if(S(j:j)==')') then
           numr2 = numr2 - 1
           if(numr.eq.0) exit
        else if(S(j:j)=='^') then
           status = status + 1
        else if(S(j:j)=='*') then
           if(status >= 2) then
              left = left + numr2
              exit
           end if
        end if
     end do
     numr2 = numr
     status = 0
     do j=i+1,len
        if(S(j:j)==')') then
           numr2 = numr2 - 1
           if(numr.eq.0) exit
        else if(S(j:j)=='^') then
           status = status * 2
           if(status == 4) then
              right = right + numr2
           end if
        else if(S(j:j)=='*') then
           if(status == 0) then
              status = 1
           end if
        end if
     end do
  end do
  print '(i0," ",i0)',left, right
end program main
0