码迷,mamicode.com
首页 > 其他好文 > 详细

CF989C A Mist of Florescence

时间:2018-06-12 16:28:03      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:有趣   ace   color   std   res   ret   int   class   总结   

思路:

有趣的构造题。

实现:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 char ans[51][51];
 4 void fillin(int x, int y, char c, int maxy, int cnt)
 5 {
 6     int a = x, b = y;
 7     while (cnt)
 8     {
 9         ans[a][b] = c;
10         if (b + 2 >= maxy) { a += 2; b = y; }
11         else b += 2;
12         cnt--;
13     }
14 }
15 int main()
16 {
17     int a, b, c, d;
18     while (cin >> a >> b >> c >> d)
19     {
20         for (int i = 0; i < 25; i++)
21         {
22             for (int j = 0; j < 25; j++)
23             {
24                 ans[i][j] = A;
25                 ans[i][j + 25] = B;
26                 ans[i + 25][j] = C;
27                 ans[i + 25][j + 25] = D;
28             }
29         }
30         fillin(1, 1, B, 25, b - 1);
31         fillin(1, 26, C, 50, c - 1);
32         fillin(26, 1, D, 25, d - 1);
33         fillin(26, 26, A, 50, a - 1);
34         cout << "50 50" << endl;
35         for (int i = 0; i < 50; i++)
36         {
37             for (int j = 0; j < 50; j++)
38                 cout << ans[i][j];
39             cout << endl;
40         }
41     }
42     return 0;
43 }

总结:

对于构造题,要尽量用简单的方法完成任务,不要自己徒增限制条件。

 

CF989C A Mist of Florescence

标签:有趣   ace   color   std   res   ret   int   class   总结   

原文地址:https://www.cnblogs.com/wangyiming/p/9173082.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!