Codeforces Round #236 (Div. 2), problem: (A) Nuts solution: http://ideone.com/B6qs7I
#include <iostream> #include <cstdio> using namespace std; int main() { int k, a, b, v, r; r=0; scanf("%d%d%d%d", &k, &a, &b, &v); while(b+1>=k && a>0) { a-=k*v; b-=k, b++; r++; } while(b+1<k && a>0) a-=(b+1)*v, b=0, r++; while(a>0) a-=v, r++; printf("%d\n", r); return 0; }
No comments:
Post a Comment