Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

直接贴代码,水题。。。

Posted by KatrineYang at 2016-05-26 21:41:39 on Problem 1606
竟然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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator