#15153: WA求解...


fdhs107_KonChin_Shih (Konchin)

學校 : 桃園市私立復旦高級中學
編號 : 69313
來源 : [140.113.168.124]
最後登入時間 :
2025-05-05 16:44:06

#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main(){
string x;
while(true){
getline(cin,x,'\n');
long a=0,b=0;
bool ab=true;
for(int t=0;t!=x.length();t++){
a+=(ab?(x[t]-'0'):0);
b+=(ab?0:(x[t]-'0'));
ab=!ab;
// cout<<"test\n"<<a<<" "<<b<<" "<<x<<endl;
}
cout<<abs(a-b)<<endl;
}
return 0;
}

#15160: Re:WA求解...


anandrewboy70900 (ShowTsai)

學校 : 國立中央大學
編號 : 27736
來源 : [203.204.218.144]
最後登入時間 :
2025-05-29 22:24:26

是TLE吧

改成while(getline(cin, x))