ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

SDNU 1155.Pizza Pricing

2019-02-23 11:51:23  阅读:332  来源: 互联网

标签:10 diameter 1155 menu Pricing inch SDNU include best


Description

Pizza has always been a staple on college campuses. After the downturn in the economy, it is more important than ever to get the best deal, namely the lowest cost per square inch. Consider, for example, the following menu for a store selling circular pizzas of varying diameter and price:

 

Menu
DiameterPrice
5 inch $2
10 inch $6
12 inch $8

One could actually compute the costs per square inch, which would be approximately 10.2¢, 7.6¢, and 7.1¢ respectively, so the 12-inch pizza is the best value. However, if the 10-inch had been sold for $5, it would have been the best value, at approximately 6.4¢ per square inch.

Your task is to analyze a menu and to report the diameter of the pizza that is the best value. Note that no two pizzas on a menu will have the same diameter or the same inherent cost per square inch.

Input

The input contains a series of one or more menus. Each menu starts with the number of options N, 1 ≤ N ≤ 10, followed by N lines, each containing two integers respectively designating a pizza's diameter D (in inches) and price P (in dollars), with 1 ≤ D ≤ 36 and 1 ≤ P ≤ 100. The end of the input will be designated with a line containing the number 0.

Output

For each menu, print a line identifying the menu number and the diameter D of the pizza with the best value, using the format shown below.

Sample Input

3
5 2
10 6
12 8
3
5 2
10 5
12 8
4
1 1
24 33
13 11
6 11
0

Sample Output

Menu 1: 12
Menu 2: 10
Menu 3: 24

Source

Mid-Central USA 2011
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

#define ll long long
const double pi = acos(-1.0);

int n, d[18], p[18], miao = 0, sum;
double s[18];
int main()
{
    while(scanf("%d", &n) && n)
    {
        sum = 0;
        for(int i = 0; i<n; i++)
        {
            scanf("%d%d", &d[i], &p[i]);
            s[i] = (double)p[i]/(pow(d[i], 2)*pi);
//            printf("%lf\n", s[i]);
        }
//        printf("\n");
        for(int i = 1; i<n; i++)
        {
            if(s[sum]>s[i])sum = i;
        }
        miao++;
        printf("Menu %d: %d\n", miao, d[sum]);
    }
    return 0;
}

 

标签:10,diameter,1155,menu,Pricing,inch,SDNU,include,best
来源: https://www.cnblogs.com/RootVount/p/10422096.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有