CodeForces 402A

来源:互联网 发布:淘宝网店域名怎么改 编辑:程序博客网 时间:2024/05/20 22:36

没有读懂题意。为什么每次划分都要减去划分出去的因子?

原题链接:http://codeforces.com/problemset/problem/402/A

#include<iostream>#include<cstring>#include<cstdlib>#include<cstdio>#include<string>#include<map>#include<set>#include<algorithm>#include<vector>//#include<cmath>using namespace std;int main (){  int k,a,b,v;  scanf ("%d%d%d%d",&k,&a,&b,&v);  int time=0;  while (a>0)  {if (b+1>k){//因子b+1--能划分的数目,k--最多划分的数目  b=b-(k-1);//因子每次都要减划分出去的因子  a-=k*v;}else{  a-=(b+1)*v;  b=0;}time++;  }  printf ("%d\n",time);  return 0;}


0 0
原创粉丝点击