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


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

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59
a065. 提款卡密碼 -- 板橋高中教學題 | From: [219.85.43.159] | 發表日期 : 2021-11-12 00:07

#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)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
a065. 提款卡密碼 -- 板橋高中教學題 | From: [27.51.64.28] | 發表日期 : 2021-11-12 10:19

#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)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
a065. 提款卡密碼 -- 板橋高中教學題 | From: [27.51.64.28] | 發表日期 : 2021-11-12 22:48


你只加速了一半。

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


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

 AC (2ms, 40KB)

 

 
ZeroJudge Forum