链接: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. android 中activity调用远程service中的方法之 aidl的使用

    服务端:只有服务,没有界面 1.编写interface文件,复制到 .aidl 文件中,并去掉其中的public 等修饰符.系统会自动在gen目录下生成对应的java文件  (对应本地调用中的接口文件 ...

  2. PayPal网站付款标准版(for PHP)

    简单整理一下PHP项目整合PayPal支付功能. 一.表单的构建: <form method="post" name="form" action=&quo ...

  3. <mvc:annotation-driven />与<context:annotation-config />

    Spring家族的配置中这两个配置的意义,说具体点其实根据标签的shecma就能看出来,mvc,主要就是为了Spring MVC来用的,提供Controller请求转发,json自动转换等功能,而co ...

  4. python读入文件

    举例说明吧,路径一定要带转义符‘\’,下面的例子中,每一行是一个样本的feature >>> myfile=open("D:\\301\\graduate_thesis\\ ...

  5. office 2016 专业增强版 和 visio 2016 专业版 下载安装(附带激活工

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://babyshen.blog.51cto.com/8405584/1697910 o ...

  6. 日常css和js小知识点记录

    2015-6-29 1.<meta name="viewport" content="width=device-width,user-scalable=no&quo ...

  7. PRINCE2七大原则(2)

    PRINCE2七大原则(2) 我们先来回顾一下,PRINCE2七大原则分别是持续的业务验证,经验学习,角色与责任,按阶段管理,例外管理,关注产品,剪裁. 第二个原则:吸取经验教训. PRINCE2要求 ...

  8. 【转】Android WebView 播放视频总结

    今天发现 WebView里播放优酷的视频点击播放按钮后没反应,于是看官方文档和搜索解决,下面是我在别人基础上做的补充:   android webView 无法播放视频,无法暂停,继续播放视频问题,无 ...

  9. C++内存分析

    在C++中,内存分成5个区,他们分别是堆.栈.自由存储区.全局/静态存储区和常量存储区. 栈:就是那些由编译器在需要的时候分配,在不需要的时候自动清除的变量的存储区.里面的变量通常是局部变量.函数参数 ...

  10. 驱动之module_init/module_exit

    在前面helloworld的编写里面,我们使用了两个宏分别是module_init和module_exit,这里分析下为什么使用这两个宏. 在写模块的时候有两个特殊的函数,分别是init_module ...