Advertisement
hasib_mo

A - Crne [O(n)]

Apr 18th, 2013
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. /*
  2. user: hasib
  3. */
  4. #include<stdio.h>
  5. int main()
  6. {
  7.     int n, half;
  8.     int i;
  9.     int maxResult = -1; //initializing with a very small value;
  10.  
  11.     scanf("%d", &n);
  12.     half = n/2;
  13.  
  14.     for(i=0; i<=half; i++)
  15.     {
  16.         if(maxResult < (i+1)*(n-i+1) )
  17.         {
  18.             maxResult = (i+1)*(n-i+1);
  19.         }
  20.     }
  21.  
  22.     printf("%d\n", maxResult);
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement