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 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Twilight 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
原创粉丝点击