ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1820. Ural Steaks

AC 0.015 120 КБ
Posted by martin 5 May 2012 14:44
#include <iostream>
#include <stdio.h>

int main()
{
    long n,k,t;
    scanf("%ld%ld",&n,&k);
    t=2*(n/k)+(n%k!=0)+((n%k>k/2.0)||(n<k));
    printf("%ld\n",t);
    return 0;
}

Edited by author 05.05.2012 14:45

Edited by author 05.05.2012 14:45
Re: AC 0.015 120 КБ
Posted by martin 5 May 2012 14:48
but sometimes 0.031. Don't know why..

Edited by author 05.05.2012 15:05
another approach
Posted by esger 31 May 2012 13:52
result is n/k+1 + (n-1+n%k)/k
to avoid WA8 check if k is greater than n.
Re: another approach
Posted by Pegasus 1 Sep 2012 08:51
Can you explain it for me? I can't understand this formular.(sorry for my English)