#28056: CPP  沒加速AC (33ms, 316KB) 加速後AC (26ms, 340KB)


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)


#include <iostream>
using namespace std;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
string str;
while(cin >> str){
for (int i=0; i<str.size()-1; i++){
cout << abs(str[i]-str[i+1]);
}
cout <<endl;
}
}
#28057: Re:CPP  沒加速AC (33ms, 316KB) 加速後AC (26ms, 340KB)


cges30901 (cges30901)


#include <iostream>
using namespace std;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
string str;
while(cin >> str){
for (int i=0; i<str.size()-1; i++){
cout << abs(str[i]-str[i+1]);
}
cout <<endl;
}
}


你只加速了一半。

把endl改成'\n'後, AC (12ms, 348KB)

#28077: Re:CPP  沒加速AC (33ms, 316KB) 加速後AC (26ms, 340KB)


cges30901 (cges30901)



你只加速了一半。

把endl改成'\n'後, AC (12ms, 348KB)


如果輸入輸出改用fgets和putchar還可以更快

 AC (2ms, 40KB)