大家注意最多只能打4针,而且题目问的是能按时打针的次数,所以要注意
#include<iostream> using namespace std; int main() { int a,b; while(cin>>a>>b) { int total=a; int sum=0; if(a<120) { cout<<"0"<<endl; continue; } if(a>=120) { while(total>0) { if(sum==4) { if(total>=100) { sum++; total-=100; } else break; } else { if(total>=120) { sum++; total-=120; } else break; } total+=b; } } if(sum>4) cout<<"4"<<endl; else cout<<sum<<endl; } return 0; }
0.0分
2 人评分