結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-12-27 23:40:45 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 912 bytes |
| コンパイル時間 | 512 ms |
| コンパイル使用メモリ | 32,000 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 01:54:55 |
| 合計ジャッジ時間 | 1,137 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
program main
implicit none
integer::N,len,i,head,tail,res,num,op
integer,parameter::add=1,mult=2
character*100::S
read '(a)',S
res = 1
op = mult
head = 1
tail = 1
len = LEN_TRIM(S)
do
if(S(tail:tail).eq.'+'.or. &
S(tail:tail).eq.'*') then
read(S(head:tail-1),*) num
if(op.eq.add) then
res = num + res
else
res = num * res
end if
if(tail.eq.len+1) then
exit
else if(S(tail:tail).eq.'+') then
op = mult
else
op = add
end if
head = tail + 1
tail = tail + 1
else if (tail.eq.len+1) then
read(S(head:tail-1),*) num
if(op.eq.add) then
res = num + res
else
res = num * res
end if
exit
else
tail = tail + 1
end if
end do
print '(i0)', res
end program main
jj