Advertisement
Guest User

Class 20.08.13

a guest
Aug 20th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <bitset>
  7. #include <iostream>
  8. #include <stack>
  9. #include <queue>
  10. #include <set>
  11. #include <map>
  12. #include <string>
  13. #include <algorithm>
  14. using namespace std;
  15.  
  16. int n, r, c, m, w;
  17. bool u[110][110];
  18.  
  19. int main() {
  20.     freopen("class.in", "r", stdin);
  21.     freopen("class.out", "w", stdout);
  22.     scanf("%d%d%d", &n, &r, &c);
  23.     m = min(r, c);
  24.     if (2 * m - 1 <= n)
  25.         w = m;
  26.     else
  27.         w = (n - 1) / 2 + 1;
  28.    
  29.     printf("%d\n", w);
  30.     for (int j = 0; j < w; j++) {
  31.         u[0][j] = 1;
  32.         n--;
  33.     }
  34.     for (int i = 1; i < w; i++) {
  35.         u[i][0] = 1;
  36.         n--;
  37.     }
  38.     for (int i = 0; i < r; i++) {
  39.         for (int j = 0; j < c; j++) {
  40.             if (u[i][j] || !n)
  41.                 continue;
  42.             u[i][j] = 1;
  43.             n--;
  44.         }
  45.     }
  46.  
  47.     for (int i = 0; i < r; i++) {
  48.         for (int j = 0; j < c; j++)
  49.             printf("%c", u[i][j] ?  '#' : '.');
  50.         printf("\n");
  51.     }
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement