Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
直接贴代码,水题。。。竟然W了一次,忘记输出每一步的empty A了,我也是没谁了! //============================================================================ // Name : main1606.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> using namespace std; int main() { int A, B, T; while(cin >> A){ cin >> B >> T; if(T%A == 0){ int ci = T/A; for(int i = 0; i < ci; i++){ cout << "fill A\npour A B\n"; } cout << "success\n"; } else{ int sB = B; cout << "fill B\n"; while(sB != T){ if(sB > A){ cout << "pour B A\nempty A\n"; sB -= A; } else{ cout << "pour B A\nfill B\npour B A\nempty A\n"; sB += (B - A); } } cout << "success\n"; } } //cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator