UVa10273 Eat or Not to Eat?
来源:互联网 发布:淘宝零食推荐知乎健康 编辑:程序博客网 时间:2024/05/01 23:19
题意:N头奶牛,第i头牛产奶有周期Ti,即第d天产量等于第d+Ti天产量。每天主人杀掉产量最少的牛,如果多头产量最少,则不会杀掉。问最后能剩下多少牛,以及最后一次杀牛的天数。
思路:模拟。如果连续若干天牛不被杀,以后就不会被杀了。那到底是连续多少天呢,直接用1~10的最小公倍数2520。。。
#include <iostream>#include <stdio.h>#include <cmath>#include <algorithm>#include <iomanip>#include <cstdlib>#include <string>#include <memory.h>#include <vector>#include <queue>#include <stack>#include <ctype.h>#define INF 1000000using namespace std;int cyc[10010];int cow[10010][12];bool eat[10010];int main(){int T;cin>>T;int N;while(T--){memset(eat,0,sizeof(eat));cin>>N;for(int i=1;i<=N;i++){cin>>cyc[i];for(int j=0;j<cyc[i];j++){cin>>cow[i][j];}}int b=0;int count=0;int last;for(int day=1;;day++){int tmp=INF;bool flag=false;int k;for(int i=1;i<=N;i++){if(eat[i])continue;if( cow[i][(day-1)%cyc[i]]<tmp ){tmp=cow[i][(day-1)%cyc[i]];k=i;flag=true;}else if( cow[i][(day-1)%cyc[i]]==tmp ){flag=false;}}if(b>2520)break;if(flag){b=0;eat[k]=true;count++;last=day;}else{b++;}}if(count){cout<<N-count<<" "<<last<<endl;}else{cout<<N-count<<" "<<0<<endl;}}return 0;}
0 0
- UVa10273 Eat or Not to Eat?
- UVA10273 - Eat or Not to Eat?(暴力)
- 10273 - Eat or Not to Eat?
- ZOJ-1236 Eat or Not to Eat?
- uva 10273 Eat or Not to Eat?
- UVA - 10273 Eat or Not to Eat?
- UVA 10273 Eat or Not to Eat?
- uva 10273 - Eat or Not to Eat?(暴力枚举)
- UVA 10273 - Eat or Not to Eat?(暴力)
- UVA - 10273 Eat or Not to Eat? 暴力
- Eat or Not to Eat? - UVa 10273 暴力
- eat
- eat
- eat out or eat in 吃货英语
- rest-work-eat-study-rest-work-eat or rest-rest-work-work-eat-eat..
- 1587. Eat or Be Eaten
- Eat at home or restaurant
- 3991. Eat or Study toj
- Hdu 1086 You can Solve a Geometry Problem too[判断线段相交,完整版]
- 20140717 随笔 技术文章安家至CSDN
- 【神经网络学习笔记】遗传算法初探
- 10 HashSet HashMap源码 Properties
- Java swing 实现高仿 QQ2013之登入界面设计
- UVa10273 Eat or Not to Eat?
- php——学习笔记,赋值运算符和递增或递减运算符和位运算符
- Tkinter中的Events事件(关于bind()的详细描述)
- Dividing - POJ 1014 dp背包
- IGraphicslayer说明
- 程序员成长历程的四个阶段
- 集合框架中的共性功能
- 使用ajax和js无刷新改变页面内容和地址栏URL
- linux服务器私钥登录