ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#207513 | #53. eval | xiaozhazha | 100 | 5ms | 512kb | C++ | 828b | 2024-07-29 10:16:07 | 2024-07-29 10:16:09 |
answer
#include<cstdio>
#include<cctype>
#define mod 1000000000
struct num{int a,b;}a[30];
inline num calc(char c){ if(isdigit(c)) return num{c-'0',0};return a[c-'A']; }
inline num add(num a,num b){ return num{(a.a+b.a)%mod,a.b|b.b|(a.a+b.a>=mod)}; }
char s[105];
inline void dfs(int now)
{
if(s[now] == 'f')
{
for(a[s[now+4]-'A']=calc(s[now+6]);;a[s[now+4]-'A']=add(a[s[now+4]-'A'],num{1,0}))
{
dfs(now+10);
if(a[s[now+4]-'A'].a==calc(s[now+8]).a) return;
}
}
else
if(s[now+1]=='+') a[s[now]-'A'] = add(a[s[now]-'A'],calc(s[now+3]));
else a[s[now]-'A'] = calc(s[now+2]);
}
int main(){
for(;scanf("%s",s)!=EOF;)
dfs(0);
for(int i=0;i<26;i++)
if(a[i].a || a[i].b){
if(a[i].b) printf("%c=...%09d\n",i+'A',a[i].a);
else printf("%c=%d\n",i+'A',a[i].a);
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 504kb
input:
O=1
output:
O=1
result:
ok single line: 'O=1'
Test #2:
score: 10
Accepted
time: 0ms
memory: 504kb
input:
C=6 B=B A=3 B=A A=0 C=C B=C C=6 B=B A=B Z=9 Y=0 I=J J=K K=L L=A L=3 A=L B=A B=B C=B C=C B=C C=0 A=B ...
output:
A=3 B=3 I=3 J=3 K=3 L=3 Z=9
result:
ok 7 lines
Test #3:
score: 10
Accepted
time: 0ms
memory: 504kb
input:
X+=9
output:
X=9
result:
ok single line: 'X=9'
Test #4:
score: 10
Accepted
time: 0ms
memory: 504kb
input:
C=6 B+=B A=3 B=A A=0 C=C B=C C=6 B=B A+=B Z=9 Y+=0 I+=J J+=K K=L L=A L=3 A=L B+=A B+=B C+=B C+=C B+=...
output:
A=405 B=3234 C=1620 I=3 J=3 K=6 L=3 Z=9
result:
ok 8 lines
Test #5:
score: 10
Accepted
time: 0ms
memory: 508kb
input:
for(I,A,6)S+=I
output:
I=6 S=21
result:
ok 2 lines
Test #6:
score: 10
Accepted
time: 0ms
memory: 504kb
input:
for(I,A,6)S+=I A=3 for(I,A,6)S+=I for(I,A,A)S+=I for(I,A,6)T=9 A=1 B=0 for(J,0,9)B+=A A=B B=0 for(J,...
output:
A=10000 B=10000 I=6 J=10000 K=10000 L=10000 S=42 T=9 X=150025001 Y=10001 Z=50005000
result:
ok 11 lines
Test #7:
score: 10
Accepted
time: 0ms
memory: 504kb
input:
for(A,0,9)for(B,0,A)for(C,B,A)for(D,B,C)for(E,D,C)for(F,D,E)for(G,F,E)for(H,F,G)for(I,H,G)Z+=I
output:
A=9 B=9 C=9 D=9 E=9 F=9 G=9 H=9 I=9 Z=218790
result:
ok 10 lines
Test #8:
score: 10
Accepted
time: 0ms
memory: 504kb
input:
for(A,0,9)for(B,0,A)for(C,B,A)for(D,B,C)for(E,D,C)for(F,D,E)for(G,F,E)for(H,F,G)for(I,H,G)Z+=1 for(A...
output:
A=9 B=9 C=9 D=9 E=9 F=9 G=9 H=9 I=9 X=9 Y=218790 Z=48620
result:
ok 12 lines
Test #9:
score: 10
Accepted
time: 1ms
memory: 508kb
input:
for(A,3,7)for(B,2,A)for(C,B,8)for(D,1,C)for(E,D,C)for(F,D,9)for(G,0,E)Z+=G
output:
A=7 B=7 C=8 D=8 E=8 F=9 G=8 Z=214641
result:
ok 8 lines
Test #10:
score: 10
Accepted
time: 4ms
memory: 512kb
input:
Z+=1 for(I,0,9)for(J,I,9)for(K,I,J)Z+=Z I=0 J=0 K=0 A=1 for(X,0,9)B+=A for(X,0,9)C+=B for(X,0,9)D+=C...
output:
A=1 B=10 C=100 D=1000 E=10000 F=100000 G=1000000 H=10000000 I=100000000 J=...000000000 K=...00000000...
result:
ok 24 lines