CF989C A Mist of Florescence
阿新 • • 發佈:2018-06-12
esp har AS clas name bit clu 條件 spa
思路:
有趣的構造題。
實現:
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 elseb += 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