10670 - Work Reduction(水题)
来源:互联网 发布:淘宝自己开店套现 编辑:程序博客网 时间:2024/06/06 13:23
对于每一个代理。
我们直接模拟就行了,看看是A方案好还是B方案好。
细节参见代码:
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int INF = 100000000;const int maxn = 100 + 5 ;int T,n,m,l,kase = 0;struct node{ char name[20]; int a,b,cost; bool operator < (const node& rhs) const { return cost < rhs.cost || (cost == rhs.cost && strcmp(name,rhs.name)<0); }}a[maxn];char s[100];int main() { scanf("%d",&T); while(T--) { scanf("%d%d%d",&n,&m,&l); for(int i=0;i<l;i++) { scanf("%s",s); int len = strlen(s), res ; for(int j=0;j<len;j++) { if(s[j] == ':') { res = j+1; a[i].name[j] = '\0'; break; } else a[i].name[j] = s[j]; } a[i].a = a[i].b = 0; for(int j=res;j<len;j++) { if(s[j] == ',') { res = j+1; break; } else a[i].a = a[i].a*10 + s[j] - '0'; } for(int j=res;j<len;j++) a[i].b = a[i].b*10 + s[j] - '0'; } for(int i=0;i<l;i++) { a[i].cost = 0; int cur = n; while(true) { int v = round(cur*1.0/2); if(cur - v < m) { a[i].cost += a[i].a*(cur - m); break; } if(v * a[i].a < a[i].b) { a[i].cost += a[i].a*(cur - m); break; } else { cur -= v; a[i].cost += a[i].b; } } } sort(a,a+l); printf("Case %d\n",++kase); for(int i=0;i<l;i++) printf("%s %d\n",a[i].name,a[i].cost); } return 0;}
0 0
- 10670 - Work Reduction(水题)
- UVa 10670 - Work Reduction(水)
- uva 10670 Work Reduction(贪心)
- uva - 10670 - Work Reduction(贪心)
- uva:10670 - Work Reduction(贪心)
- Uva-10670 Work Reduction(贪心)
- uva 10670 Work Reduction (贪心)
- UVa 10670 - Work Reduction
- UVa 10670 - Work Reduction
- uva 10670 - Work Reduction
- 10670 - Work Reduction
- UVA 10670 Work Reduction
- UVA 10670 - Work Reduction
- uva 10670 - Work Reduction
- uva 10670 Work Reduction
- UVa:10670 Work Reduction
- uva 10670 - Work Reduction
- UVa 10670 - Work Reduction
- [总结]机房收费系统 条件判断
- Android Fragment 生命周期图
- 为什么做javaweb要用到框架
- solr定时实时重建索引和增量更新
- Traits的用法
- 10670 - Work Reduction(水题)
- CentOS6.5 PHP5.4.0+Apache2.4.1+MySQL5.5.21 编译安装
- web项目欢迎页设置
- iOS UI基础知识
- 面试笔试细节汇总
- 欢迎使用CSDN-markdown编辑器
- Traits的用法
- 从零开始学WPF Prism框架(一) 系列博文说明及目录
- vim :s命令使用笔记