Baby Step, Giant Step

  • + 0 comments

    Java

    public static int solve(int a, int b, int d) {
      if(d == 0) return 0;
      if(d == b || d == a) return 1;
      if(d < 2 * b) return 2;
      return d/b + (d%b==0?0:1);
    }