链接:http://codeforces.com/contest/454/problem/A

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 size n. 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.

Sample test(s)
input
3
output
*D*
DDD
*D*
input
5
output
**D**
*DDD*
DDDDD
*DDD*
**D**
input
7
output
***D***
**DDD**
*DDDDD*
DDDDDDD
*DDDDD*
**DDD**
***D*** 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
看样例就知道了,直接模拟即可
 #include <stdio.h>
#include <string.h>
#include <stdlib.h> int main()
{
int i,j,n,m,k,t;
while(scanf("%d",&n)!=EOF)
{
int tmp1=n/,tmp2=n/,tmp3=;
for(i=;i<=n/;i++)
{
for(j=;j<=tmp1;j++)
printf("*");
for(j=tmp1;j<=tmp2;j++)
printf("D");
for(j=tmp2+;j<=n;j++)
printf("*");
printf("\n");
tmp1--;tmp2++;
}
for(i=;i<=n;i++)
printf("D");
printf("\n");
tmp1=,tmp2=n;
for(i=;i<=n/;i++)
{
for(j=;j<=tmp1;j++)
printf("*");
for(j=tmp1+;j<=tmp2-;j++)
printf("D");
for(j=tmp2;j<=n;j++)
printf("*");
tmp1++;tmp2--;
printf("\n");
}
}
return ;
}

B:http://codeforces.com/contest/454/problem/B

B. Little Pony and Sort by Shift
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

One day, Twilight Sparkle is interested in how to sort a sequence of integers a1, a2, ..., an in non-decreasing order. Being a young unicorn, the only operation she can perform is a unit shift. That is, she can move the last element of the sequence to its beginning:

a1, a2, ..., an → an, a1, a2, ..., an - 1.

Help Twilight Sparkle to calculate: what is the minimum number of operations that she needs to sort the sequence?

Input

The first line contains an integer n (2 ≤ n ≤ 105). The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 105).

Output

If it's impossible to sort the sequence output -1. Otherwise output the minimum number of operations Twilight Sparkle needs to sort it.

Sample test(s)
input
2
2 1
output
1
input
3
1 3 2
output
-1
input
2
1 2
output
0

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
//////////////////////////////////////////////////////
模拟题,判断每两个出现递减的,算出有多少个递减的,如果有两个以上的,就是不行的,
当为零,说明没有递减的,为一需判断起点与终点的大小,可不可以接上
 #include <stdio.h>
#include <string.h>
#include <stdlib.h> int str[]; int main()
{
int n,m,i,j;
while(scanf("%d",&n)!=EOF)
{
for(i=; i<=n; i++)
{
scanf("%d",&str[i]);
}
int sum=,tmp;
for(i=; i<=n; i++)
{
if(str[i]<str[i-])
{
sum++;
tmp=i;
} }
if(sum == )printf("0\n");
else if(sum > )printf("-1\n");
else if(sum == && str[n] <= str[])
printf("%d\n",n-tmp+);
else printf("-1\n");
}
return ;
}

今天没事干,模拟了下CF,只做了A题,模拟速度超慢  A题模拟了15min,B题想了一会没思路,就取看C题,找了一会规律没找到,

就这样结束了……

C题组合数学,看不太懂题解,
AC不易,且行且珍惜……

Codeforces Round #259 (Div. 2)AB的更多相关文章

  1. Codeforces Round #713 (Div. 3)AB题

    Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...

  2. Codeforces Round #260 (Div. 2)AB

    http://codeforces.com/contest/456/problem/A A. Laptops time limit per test 1 second memory limit per ...

  3. Codeforces Round #555 (Div. 3) AB

    A:    http://codeforces.com/contest/1157/problem/A 题意:每次加到10的整数倍之后,去掉后面的0,问最多有多少种可能. #include <io ...

  4. Codeforces Round #259 (Div. 1) A. Little Pony and Expected Maximum 数学公式结论找规律水题

    A. Little Pony and Expected Maximum Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.c ...

  5. Codeforces Round #259 (Div. 2)

    A. Little Pony and Crystal Mine 水题,每行D的个数为1,3.......n-2,n,n-2,.....3,1,然后打印即可 #include <iostream& ...

  6. Codeforces Round #259 (Div. 2)-D. Little Pony and Harmony Chest

    题目范围给的很小,所以有状压的方向. 我们是构造出一个数列,且数列中每两个数的最大公约数为1; 给的A[I]<=30,这是一个突破点. 可以发现B[I]中的数不会很大,要不然就不满足,所以B[I ...

  7. Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum (数学期望)

    题目链接 题意 : 一个m面的骰子,掷n次,问得到最大值的期望. 思路 : 数学期望,离散时的公式是E(X) = X1*p(X1) + X2*p(X2) + …… + Xn*p(Xn) p(xi)的是 ...

  8. Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum

    题目链接 题意:一个m个面的骰子,抛掷n次,求这n次里最大值的期望是多少.(看样例就知道) 分析: m个面抛n次的总的情况是m^n, 开始m==1时,只有一种 现在增加m = 2,  则这些情况是新增 ...

  9. Codeforces Round #259 (Div. 2) D. Little Pony and Harmony Chest 状压DP

    D. Little Pony and Harmony Chest   Princess Twilight went to Celestia and Luna's old castle to resea ...

随机推荐

  1. 查找(顺序表&有序表)

    [1]查找概论 查找表是由同一类型是数据元素(或记录)构成的集合. 关键字是数据元素中某个数据项的值,又称为键值. 若此关键字可以唯一标识一个记录,则称此关键字为主关键字. 查找就是根据给定的某个值, ...

  2. 电脑远程工具:mstsc

    外网远程控制:电脑远程连接在开始程序中搜:mstsc  然后直接敲IP地址 工具:dell sonicwall netextender.exe    mstsc.exe 内网远程控制:使用TeamVi ...

  3. 【jqGrid for ASP.NET MVC Documentation】.学习笔记.2.jqGrid Model-View-Controller 分离

    1 基本 分离代码 和 描述 ,在ASP.NET MVC 应用程序中是非常重要的.因此,jqGrid 的 mvc 模式使用一个共同的网格安装设置,包括 Model ,Controller 和 View ...

  4. php的header()函数之设置content-type

    //定义编码 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header('Content-type: application/at ...

  5. ecshop简单三部实现导航分类二级菜单

    1.在page_header.lbi对应的位置(你想显示导航的位置)插入 (注意下面的"themes/模板名称/util.php"中的"模板名称"改成你模板文件 ...

  6. Bellman-Ford 算法及其优化

    Bellman-Ford 算法及其优化 转自:http://hi.baidu.com/jzlikewei/blog/item/94db7950f96f995a1038c2cd.html Bellman ...

  7. Djnago的一些零碎知识点

    1.TEMPLATE_DIRS relative to the project folder http://stackoverflow.com/questions/9856683/using-pyth ...

  8. Uva 1220,Hali-Bula 的晚会

    题目链接:https://uva.onlinejudge.org/external/12/1220.pdf 题意: 公司n个人,形成一个数状结构,选出最大独立集,并且看是否是唯一解. 分析: d(i) ...

  9. js获取页面高度赋值给div

    <script type="text/javascript"> window.onload=function(){ map_width=document.body.cl ...

  10. 无聊安装的Microsoft SQL Server2016步骤

    SQL Server 下载 ed2k://|file|cn_sql_server_2016_enterprise_x64_dvd_8699450.iso|2452795392|D8AFD8D6245F ...