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

晕死,变量定义重复WA一次。。。附不用数组的解法,0ms

Posted by KatrineYang at 2016-11-14 10:58:27 on Problem 1547
#include <iostream>
#include <cstring>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
string f_ = " took clay from ";
int main() {
	int n;
	while(1){
		cin >> n;
		if(n<0)break;
		if(n==2){
			int a,b,c,d,e,f; string s,t;
			cin >> a>>b>>c>>s>>d>>e>>f>>t;
			if(a*b*c>d*e*f) cout << s << f_ << t << "." << endl;
			else cout << t << f_ << s << "." << endl;
			continue;
		}
		int d,z,x, st=0;
		string ds,zs,xs;
		bool dd = 0;
		for(int i = 0; i < n; i++){

			int a,b,c;string s;
			cin >> a >> b >> c >> s;
			if(dd) continue;
			int p = a*b*c;
			if(st==0){
				d=p;ds=s;st=1;
			}
			else if(st==1){
				if(p>d){
					z=d;zs=ds;d=p;ds=s;st=2;
				}
				else if(p<d){
					z=p;zs=s;st=2;
				}
			}
			else if(st==2){
				if(p>d){
					x=z;xs=zs;z=d;zs=ds;d=p;ds=s;st=3;
				}
				else if(p<d && p>z){
					x=z;xs=zs;z=p;zs=s;st=3;
				}
				else if(p<z){
					x=p;xs=s;st=3;
				}
			}
			else{
				cout << ds << f_ << xs << "." << endl;
				dd=1;
			}
		}
		if(!dd){
			cout << ds << f_ << xs << "." << endl;
		}
	}
	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