SRM 633 DIV2 A
来源:互联网 发布:mac app store更改用户 编辑:程序博客网 时间:2024/04/30 21:13
Problem Statement
Here at [topcoder], we call a contestant a "target" if their rating is 3000 or more. In the arena, the targets have a red icon with a small target on it. Do you want to become a target as well? Sure you do. But before you get there, let's start with something easier: drawing a target.The target you need to draw consists of nested squares. The innermost square is just a single '#' character. The larger squares use alternatingly the character ' ' (space) and the character '#'. Here is an example in which the side of the largest square isn = 5:
###### ## # ## ######
And here is an example for n = 9:
########## ## ##### ## # # ## # # # ## # # ## ##### ## ##########
You will be given an int n. Your method must return a vector <string> which contains a drawing of the target with siden. More precisely, each element of the returned vector <string> must be one row of the drawing, in order. Therefore, the returned vector <string> will consist ofn elements, each withn characters. (See the examples below for clarification.)
The value of n will be such that a target like the ones above can be drawn: 5, 9, 13, and so on. Formally,n will be of the form 4k+1, where k is a positive integer.
Definition
Class:TargetMethod:drawParameters:intReturns:vector <string>Method signature:vector <string> draw(int n)(be sure your method is public)Limits
Time limit (s):2.000Memory limit (MB):256Constraints
-n will be between 5 and 49, inclusive.-n mod 4 will be 1.Examples
0)5
Returns: {"#####", "# #", "# # #", "# #", "#####" }1)
9
Returns: {"#########", "# #", "# ##### #", "# # # #", "# # # # #", "# # # #", "# ##### #", "# #", "#########" }2)
13
Returns: {"#############", "# #", "# ######### #", "# # # #", "# # ##### # #", "# # # # # #", "# # # # # # #", "# # # # # #", "# # ##### # #", "# # # #", "# ######### #", "# #", "#############" }3)
17
Returns: {"#################", "# #", "# ############# #", "# # # #", "# # ######### # #", "# # # # # #", "# # # ##### # # #", "# # # # # # # #", "# # # # # # # # #", "# # # # # # # #", "# # # ##### # # #", "# # # # # #", "# # ######### # #", "# # # #", "# ############# #", "# #", "#################" }
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.
找规律画图啊……
class Target{private:bool pic[60][60];void draw(int x,int y,int n){if(n<1)return;for(int i=0;i<n;i++){pic[x][y+i]=1;pic[x+n-1][y+i]=1;pic[x+i][y]=1;pic[x+i][y+n-1]=1;}draw(x+2,y+2,n-4);}public:vector <string> draw(int n){memset(pic,0,sizeof(pic));draw(0,0,n);vector<string>ans;for(int i=0;i<n;i++){string s;for(int j=0;j<n;j++)s+=pic[i][j]?'#':' ';ans.push_back(s);}return ans;}};
0 0
- SRM 633 DIV2 A
- SRM 670 div2 A
- SRM 670 div2 A BearSong
- Topcoder SRM 636 Div2 A
- TopCoder SRM 637 Div2 A
- [TC] SRM 633 div2 250
- TopCoder SRM 633 Div2 Problem 500 - Jumping
- SRM 114 DIV2 [550]
- SRM 398 DIV2 [250]
- SRM 399 DIV2 [250]
- SRM 387 DIV2 [250]
- SRM 387 DIV2 [600]
- SRM 397 DIV2 [500]
- SRM 400 DIV2 [250]
- SRM 400 DIV2 [500]
- SRM 397 DIV2 [1000]
- SRM 405 DIV2
- SRM 421Div2 500
- 蓝桥杯训练题
- iOS visual format
- Android4.0的Alertdialog对话框,设置点击其他位置不消失
- 【升级篇】JBPM4.4过渡到Activiti
- VS2010修改菜单字体
- SRM 633 DIV2 A
- Android使用工具方法-检测服务是否正在运行
- Eclipse上GIT插件EGIT使用手册
- (三十四)NavigationController初步
- ArcGIS教程:什么是地统计?
- Android中的广播
- make savedefconfig
- Android中Context详解
- Java过滤器和拦截器