Advertisement
apl-mhd

supersum

Sep 24th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5.   int  paint(int w, int h, long long m){
  6.  
  7.     int area, rt, temp = 0,i,j, multi;
  8.  
  9.         area = w * h;
  10.  
  11.         if(w > h){
  12.             temp = w;
  13.             w=h;
  14.             h= temp;
  15.         }
  16.         temp = 0;
  17.  
  18.  
  19.         if( area == m ){
  20.  
  21.             rt = area;
  22.  
  23.  
  24.         }
  25.  
  26.         else{
  27.             for(i =1; i<=h; i++){
  28.  
  29.                 for( j =1; j <= w; j++){
  30.  
  31.                     area = i * j;
  32.  
  33.                     if( area > m )
  34.                         break;
  35.  
  36.                     else if(area > temp){
  37.  
  38.                         temp = area;
  39.                     }
  40.  
  41.                 }
  42.  
  43.                 rt = temp;
  44.             }
  45.  
  46.  
  47.         }
  48.  
  49.  
  50.     return rt;
  51.   }
  52.  
  53. int main()
  54.  
  55. {
  56.  
  57.     int a, b, c;
  58.  
  59.     scanf("%d%d%d",&a,&b,&c);
  60.     printf("%d\n",paint(a,b,c));
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement