Monday, 19 December 2016

Solution of URI 2334 :: Little Ducks


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>

int main()
{
    unsigned long long int n;
    while(scanf("%llu", &n))
    {
        if(n == -1ll) break;
        if(n == 0ll) printf("0\n");
        else printf("%llu\n", n - 1ll);
    }
    return 0;
}

4 comments:

  1. if(n == -1ll) break;
    if(n == 0ll) printf("0\n");
    please explain these line

    ReplyDelete
    Replies
    1. u can try :
      /*
      * Little Ducks.
      */

      #include
      int main(){
      unsigned long long int p, r;
      while(1){
      scanf("%llu", &p);
      if(p == -1) break;
      else if(p == 0) printf("%llu\n", p);
      //r = p - 1;
      else if(p != 0) printf("%llu\n", p-1);
      }
      return 0;
      }

      Delete
  2. No need this you can try this if(n==-1) break; if(n==0)print("0\n");

    ReplyDelete

Note: only a member of this blog may post a comment.