#23491: C++解答 供參考


rakyjack (WaYe)

學校 : 國立中興大學
編號 : 103345
來源 : [49.217.174.139]
最後登入時間 :
2023-10-22 16:49:22
e283. APCS 類似題 - 小崴的特殊編碼 -- 小崴系列APCS | From: [111.252.105.62] | 發表日期 : 2020-11-22 16:21

#include <iostream>

#include <string>

using namespace std;

int main(){

ios::sync_with_stdio(false);

cin.tie(0);

int iTimes;

string sCode;

while(cin>>iTimes){

        sCode='\n';

        getline(cin,sCode);

for(int i=0;i<iTimes;i++){

            getline(cin,sCode);

if(sCode=="0 1 0 1")

cout<<"A";

else if(sCode=="0 1 1 1")

cout<<"B";

else if(sCode=="0 0 1 0")

cout<<"C";

else if(sCode=="1 1 0 1")

cout<<"D";

else if(sCode=="1 0 0 0")

cout<<"E";

else if(sCode=="1 1 0 0")

cout<<"F";

}

        cout<<'\n'<<flush;

}

return 0;

}

 

使用ios::sync_with_stdio(false);和cin.tie(0);來加速cin/cout避免測資5 TLE

 
ZeroJudge Forum