链接:http://codeforces.com/contest/454/problem/A
1 second
256 megabytes
standard input
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.
The only line contains an integer n (3 ≤ n ≤ 101; n is odd).
Output a crystal of size n.
3
*D*
DDD
*D*
5
**D**
*DDD*
DDDDD
*DDD*
**D**
7
***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
1 second
256 megabytes
standard input
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?
The first line contains an integer n (2 ≤ n ≤ 105). The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 105).
If it's impossible to sort the sequence output -1. Otherwise output the minimum number of operations Twilight Sparkle needs to sort it.
2
2 1
1
3
1 3 2
-1
2
1 2
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的更多相关文章
-
Codeforces Round #713 (Div. 3)AB题
Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...
-
Codeforces Round #260 (Div. 2)AB
http://codeforces.com/contest/456/problem/A A. Laptops time limit per test 1 second memory limit per ...
-
Codeforces Round #555 (Div. 3) AB
A: http://codeforces.com/contest/1157/problem/A 题意:每次加到10的整数倍之后,去掉后面的0,问最多有多少种可能. #include <io ...
-
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 ...
-
Codeforces Round #259 (Div. 2)
A. Little Pony and Crystal Mine 水题,每行D的个数为1,3.......n-2,n,n-2,.....3,1,然后打印即可 #include <iostream& ...
-
Codeforces Round #259 (Div. 2)-D. Little Pony and Harmony Chest
题目范围给的很小,所以有状压的方向. 我们是构造出一个数列,且数列中每两个数的最大公约数为1; 给的A[I]<=30,这是一个突破点. 可以发现B[I]中的数不会很大,要不然就不满足,所以B[I ...
-
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)的是 ...
-
Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum
题目链接 题意:一个m个面的骰子,抛掷n次,求这n次里最大值的期望是多少.(看样例就知道) 分析: m个面抛n次的总的情况是m^n, 开始m==1时,只有一种 现在增加m = 2, 则这些情况是新增 ...
-
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 ...
随机推荐
-
@font-face 的用法
现在很多设计用的字体都是五花八门的.我们切图又不能很好的让搜索爬虫搜索.就会使用@font-face方法: @Font-face目前浏览器的兼容性: Webkit/Safari(3.2+):TrueT ...
-
第十五章:输入和输出(I/O)
一:流分类 抽象基类:InputStream和Reader 抽象类不能用于创建模板哦! OutputStream和Writer 方向: 以内存为中心! 输入流(读) 输出流(写) 数据 ...
-
hdu 4289 最大流拆点
大致题意: 给出一个又n个点,m条边组成的无向图.给出两个点s,t.对于图中的每个点,去掉这个点都需要一定的花费.求至少多少花费才能使得s和t之间不连通. 大致思路: 最基础的拆点最大 ...
-
Magento控制器
提到模型-视图-控制器这种MVC架构,要追溯到Smalltalk编程语言和Xerox Parc.从那个时候开始,就有许多系统将自己描述为MVC架构.这些系统虽然在某些地方有细微差别,但都实现了数据层, ...
-
C# dev GridControl绑定数据不能显示
如题, dev GridControl绑定数据不能显示时可检查数据操作顺序 view = advBandedGridView1 as AdvBandedGridView; //第1 this.advB ...
-
Java ThreadFactory接口用法
根据需要创建新线程的对象.使用线程工厂就无需再手工编写对 new Thread 的调用了,从而允许应用程序使用特殊的线程子类.属性等等. JDK中的介绍: An object that creat ...
-
Python爬虫! 单爬,批量爬,这都不是事!
昨天做了一个煎蛋网妹子图的爬虫,个人感觉效果不错.但是每次都得重复的敲辣么多的代码(相比于Java或者其他语言的爬虫实现,Python的代码量可谓是相当的少了),就封装了一下!可以实现对批量网址以及单 ...
-
51nod“省选”模测第二场 C 小朋友的笑话(线段树 set)
题意 题目链接 Sol 直接拿set维护\(li\)连续段.因为set内的区间互不相交,而且每个线段会被至多加入删除一次,所以复杂度是对的. #include<bits/stdc++.h> ...
-
STL-容器库000
容器库已经作为class templates 实现. 容器库中是编程中常用的结构: (1)动态数组结构vector: (2)队列queue: (3)栈stack: (4)heaps 堆priority ...
-
vi/vim 常用命令 之 一图定天下!
直接上干活,一张图解决~