国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

PAT 1020 月餅

2019-11-08 02:28:36
字體:
供稿:網(wǎng)友
#include<stdio.h>#include<algorithm>using namespace std;struct yue{ double storage; double sumPRice; double price;};bool comp(yue a,yue b){ return a.price>=b.price;}int main(){ int a;//種類 int b;//需求量 int i; int cnt,sum,sum3; double sum2=0; yue d[1000]; scanf("%d%d",&a,&b); for(i=0;i<a;i++){ scanf("%lf",&d[i].storage); } for(i=0,sum3=0;i<a;i++){ scanf("%lf",&d[i].sumprice); d[i].price=d[i].sumprice/d[i].storage; sum3+=d[i].sumprice; } sort(d,d+i,comp); for(i=0,cnt=0,sum=d[0].storage;i<a;i++){ if(b<sum) break; cnt++; sum+=d[i+1].storage; } if(sum<b) printf("%d.00/n",sum3); else{ for(i=0;i<cnt;i++){ sum2+=d[i].sumprice; b-=d[i].storage; } sum2+=b*d[i].price; printf("%.2f/n",sum2); } return 0; }
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 丹江口市| 沾化县| 太和县| 丰镇市| 平阴县| 托里县| 太仆寺旗| 买车| 乡城县| 杂多县| 钟山县| 上蔡县| 拉萨市| 浮梁县| 墨竹工卡县| 元江| 景泰县| 元阳县| 吴桥县| 合肥市| 栾川县| 从江县| 连云港市| 丰县| 乃东县| 宜宾县| 丽江市| 长海县| 积石山| 新巴尔虎右旗| 徐闻县| 砀山县| 嵊泗县| 西城区| 龙泉市| 石城县| 鲜城| 江都市| 尚义县| 汤阴县| 丹棱县|