QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#182902 | #6750. Calculate | Kewu | WA | 2ms | 3664kb | C++11 | 553b | 2023-09-18 18:47:24 | 2023-09-18 18:47:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=5e3+10;
char Map[N];
int main()
{
gets(Map+1);int n=strlen(Map+1);
int ans=0;
for(int i=1;i<=n;++i)
{
if(Map[i]!='?'&&(Map[i]<'0'||Map[i]>'9')) continue;
int flag=1;
for(int j=1;j<i;++j)
if(Map[j]=='-') flag=-flag;
if(Map[i]=='?')
{
if(flag==1)
ans+=9;
}
else ans+=flag*(Map[i]-'0');
}
cout<<ans<<endl;
// system("pause");
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3664kb
input:
?+?
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
(?+9)-(?+1)
output:
17
result:
ok 1 number(s): "17"
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3644kb
input:
((9)-(((8)-(2))+(((1+(1))-(1+((2)+2+2)))+(5)+4))+(((7)-((9)+3))-((8)-(0-(2))+0))+((6)-(6+(((4)-(9))-(8-((9)+(1))+(0)))+(2-((9)+7))-(1)))-((((7)+(1))-((3)+(3)))-((2)-((6)-((3)-(8)))))+(2+0-((6)-(1))))-((((3)-(((0)+((4)-(9))+((6+8)+4)+(5)-(4-(3)-(8)))-((8)-(2))))+(((2)-(4))+(6)-(2))+(6-(1))-((2+9)-(3+...
output:
42
result:
wrong answer 1st numbers differ - expected: '-63', found: '42'