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-08-27 05:52:22 on Problem 1215
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

double H2O[5][3] = {{0.1, 0.06, 0.02},
					{0.25, 0.15, 0.05},
					{0.53, 0.33, 0.13},
					{0.87, 0.47, 0.17},
					{1.44, 0.80, 0.30}};

inline int mx(int a, int b){
	return a>b ? a : b;
}

inline int mn(int a, int b){
	return a<b ? a : b;
}

inline int ws(int n){
	if(n < 10) return 1;
	if(n < 100) return 2;
	if(n < 1000) return 3;
	return 4;
}

int main() {
	while(1){
		string str;
		getline(cin, str);
		if(str[0] == '#') break;
		int dist = str[0] - 'A';
		int t1 = 0, t2 = 0, t3 = 0;
		int startH = 10 * (str[11]-'0') + str[12] - '0',
			startM = 10 * (str[14]-'0') + str[15] - '0',
			endH = 10 * (str[17]-'0') + str[18] - '0',
			endM = 10 * (str[20]-'0') + str[21] - '0';
		int start = startH * 60 + startM, end = endH * 60 + endM;
		if(start < end){
			for(int j = start; j < end; j++){
				if(j >= 480 && j < 1080) t1++;
				else if(j >= 1080 && j < 1320) t2++;
				else t3++;
			}
		}
		else if(start > end){
			for(int j = end; j < start; j++){
				if(j >= 480 && j < 1080) t1++;
				else if(j >= 1080 && j < 1320) t2++;
				else t3++;
			}
			t1 = 600-t1, t2 = 240-t2, t3 = 600-t3;
		}
		else{
			t1 = 600, t2 = 240, t3 = 600;
		}
		double price = H2O[dist][0]*t1 + H2O[dist][1]*t2 + H2O[dist][2]*t3;
		printf("  ");
		for(int i = 2; i <= 9; i++){
			printf("%c", str[i]);
		}
		int ws1 = ws(t1), ws2 = ws(t2), ws3 = ws(t3);
		for(int i = 0; i < 6-ws1; i++) printf(" ");
		printf("%d", t1);
		for(int i = 0; i < 6-ws2; i++) printf(" ");
		printf("%d", t2);
		for(int i = 0; i < 6-ws3; i++) printf(" ");
		printf("%d", t3);
		printf("  %c", str[0]);
		int p_ = (int)price;
		int wsp = ws(p_);
		for(int i = 0; i < 5-wsp; i++) printf(" ");
		printf("%.2lf\n", price);
	}
	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