Codeforces Round #259 (Div. 2) A. Little Pony and Crystal Mine
来源:互联网 发布:电脑课本软件 编辑:程序博客网 时间:2024/06/05 17:33
A. Little Pony and Crystal Mine
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputTwilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n > 1) is an n × n matrix with a diamond inscribed into it.
You are given an odd integer n. You need to draw a crystal of sizen. The diamond cells of the matrix should be represented by character "D". All other cells of the matrix should be represented by character "*". Look at the examples to understand what you need to draw.
Input
The only line contains an integer n (3 ≤ n ≤ 101;n is odd).
Output
Output a crystal of size n.
Examples
Input
3
Output
*D*DDD*D*
Input
5
Output
**D***DDD*DDDDD*DDD***D**
Input
7
Output
***D*****DDD***DDDDD*DDDDDDD*DDDDD***DDD*****D***ac代码:#include<stdio.h>#include<math.h>#include<string.h>#include<stack>#include<set>#include<queue>#include<vector>#include<iostream>#include<algorithm>#define MAXN 1010000#define LL long long#define ll __int64#define INF 0xfffffff#define mem(x) memset(x,0,sizeof(x))#define PI acos(-1)#define eps 1e-8using namespace std;ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}ll lcm(ll a,ll b){return a/gcd(a,b)*b;}ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}//headint main(){int n;while(scanf("%d",&n)!=EOF){int l=n/2+1,r=n/2+1;for(int i=1;i<=n;i++){int j=1;while(j<l)printf("*"),j++;while(j<=r)printf("D"),j++;while(j<=n)printf("*"),j++;printf("\n");if(i>=n/2+1)l++,r--;elsel--,r++;}}return 0;}
0 0
- Codeforces Div. 2 #259-A. Little Pony and Crystal Mine
- Codeforces Round #259 (Div. 2) A. Little Pony and Crystal Mine
- Codeforces Round #259 (Div. 2) A-Little Pony and Crystal Mine
- Codeforces Round #259 (Div. 2) A.Little Pony and Crystal Mine
- Codeforces Round #259 (Div. 2) A. Little Pony and Crystal Mine(简单模拟实现题)
- Codeforces Round #259 (Div. 2) 454A Little Pony and Crystal Mine(模拟)
- Codeforces Round #259 (Div. 2) A. Little Pony and Crystal Mine
- Codeforces Round #259 (Div. 2) problemsA Little Pony and Crystal Mine
- Codeforces 454A. Little Pony and Crystal Mine
- Codeforces 454A Little Pony and Crystal Mine(水题)
- codeforces 454A Little Pony and Crystal Mine
- A. Little Pony and Crystal Mine
- A. Little Pony and Crystal Mine
- CF 454A(Little Pony and Crystal Mine-画图[水])
- CF 453A . Little Pony and Crystal Mine
- cf 454A Little Pony and Crystal Mine
- Codeforces Round #259 (Div. 1) A. Little Pony and Expected Maximum
- Codeforces Round #259 (Div. 1) A Little Pony and Expected Maximum
- java.lang.IllegalArgumentException: Page directive: invalid value for import
- Gradle之dependencies
- 分享秦刚老师推荐的《降级论》(罗浩原著),讲了如何跨界
- next_permutation函数
- PAT-A1036 Boys vs Girls(25) (模拟)
- Codeforces Round #259 (Div. 2) A. Little Pony and Crystal Mine
- HDOJ-2052(Picture)
- 快速排序
- [GDKOI2016]QT与泰剧
- 转行自学android,Day9-彻底蒙圈
- 浑浑噩噩
- 【JAVA】25、应用1——数组排列
- PAT-A1031 Hello World for U (20)(模拟)
- http中post 和 get 请求方法区别