Codeforces Round #132 (Div. 2)
转载请注明出处,谢谢 http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove
表示没有rate,没动力。。。
A. Bicycle Chain
很少,找出比例最大的有多少个,暴力
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#define N 2000000#define LL long long#define inf 1<<29#define eps 1e-7using namespace std;int n,m;LL t,T,x,cost;int main(){while(scanf("%d%d",&n,&m)!=EOF){LL ans=0;for(int i=0;i<n;i++){scanf("%I64d%I64d%I64d%I64d",&t,&T,&x,&cost);LL temp;if(t>=T)ans+=cost+m*x;else{LL p=T-t;LL k=m/p+(m%p==0?0:1);temp=k*cost;if(p*x<=cost)temp=min(temp,cost+x*m);else{LL num=m%p+p;if(m%p==0)num+=p;if(num<=m)temp=min(cost*(k-1)+num*x,temp);}ans+=temp;}}printf("%I64d\n",ans);}return 0;}E. Periodical Numbers
求区间内,二进制出现循环节的数有多少个,求指导