1 条题解
-
0
C++ :
#include<bits/stdc++.h> using namespace std; long long a[101010],cnt=1,sum=0; char c[101010]; int main() { cin>>a[cnt]; a[cnt]%=10000; while(cin>>c[cnt]) { cin>>a[++cnt]; a[cnt]%=10000; } for(int i=cnt;i>=1;i--) { if(c[i]=='*') { a[i]*=a[i+1]; a[i]%=10000; a[i+1]=0; } } for(int i=1;i<=cnt;i++) { sum+=a[i]; sum%=10000; } cout<<sum; }
Pascal :
var a:array [1..100001] of integer; b:array [1..100001] of char; s:string;z:char;h,i,j:longint; begin while not eof do begin read(z); s:=''; while z in ['0'..'9'] do begin s:=s+z; read(z); end; i:=i+1; val(s,j); a[i]:=j mod 10000; b[i]:=z; end; for j:=1 to i do if b[j]='*' then begin a[j+1]:=a[j]*a[j+1] mod 10000; a[j]:=0; end; for j:=1 to i do h:=h+a[j]; write(h mod 10000); end.
- 1
信息
- ID
- 700
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 4
- 已通过
- 1
- 上传者