#19820: WTF


jack621224 (YJLegend)

學校 : 政治大學
編號 : 74898
來源 : [140.113.213.67]
最後登入時間 :
2023-10-06 04:18:11
a271. 彩色蘿蔔 -- 兔子 | From: [140.119.121.6] | 發表日期 : 2019-11-02 17:03

AC

#include #include using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); int c; cin >> c; for(;c>0;c--){ int x,y,z,w,n,m,poi=0; cin >> x >> y >> z >> w >> n >> m; stringstream stream; string s; getline(cin ,s); getline(cin,s); stream<<s; int type=0; do{ m-=poi; if(m<=0) break; if(type==1) m+=x; else if(type==2) m+=y; else if(type==3) m-=z; else if(type==4) {m-=w;poi+=n;} }while(stream>>type); if(m>0) cout << m << "g\n" ; else cout << "bye~Rabbit\n"; } }

WA

 

#include #include using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); int c; cin >> c; for(;c>0;c--){ int x,y,z,w,n,m,poi=0; cin >> x >> y >> z >> w >> n >> m; stringstream stream; string s; getline(cin ,s); getline(cin,s); stream<<s; int type=0; while(stream>>type){ m-=poi; if(m<=0) break; if(type==1) m+=x; else if(type==2) m+=y; else if(type==3) m-=z; else if(type==4) {m-=w;poi+=n;} } if(m>0) cout << m << "g\n" ; else cout << "bye~Rabbit\n"; } }

 
#19822: Re:WTF


jack621224 (YJLegend)

學校 : 政治大學
編號 : 74898
來源 : [140.113.213.67]
最後登入時間 :
2023-10-06 04:18:11
a271. 彩色蘿蔔 -- 兔子 | From: [140.119.121.6] | 發表日期 : 2019-11-02 17:05

為什麼while法會錯do-while會對WTF

是因為測資有第一天體重就0的???

 
ZeroJudge Forum