Codeforces Round #259 (Div. 2)AB
链接: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 ...
随机推荐
- WordPress博客网站fonts.useso加载慢解决办法
WordPress博客网站fonts.useso加载慢解决办法 之前WordPress博客因为google字体库访问不了替换成360的useso,最近WordPress博客网站一直等待fonts.us ...
- laravel 目录结构
图 1.1 显示了 Laravel 项目目录结构是什么样子: 图1.1 Laravel 项目目录结构 就如你看到这样,laravel下面只包含了4个文件夹,这4个文件夹下面有一些子文件夹,这种丰富的子 ...
- redis监控状态
Redis介绍 Redis是一种高级key-value数据库.它跟memcached类似,不过数据可以持久化,而且支持的数据类型很丰富.有字符串,链表.哈希.集合和有序集合5种.支持在服务器端计算集合 ...
- Makefile学习之make 的运行【转】
转自:http://blog.csdn.net/suzilong11/article/details/7852830 —————— 一般来说,最简单的就是直接在命令行下输入make命令,make命令会 ...
- mysql表导入到oracle
一.创建jack表,并导入一下数据 mysql),flwo )) engine=myisam; Query OK, rows affected (0.08 sec) mysql> load da ...
- Function对象属性和方法
/* var pattern = /^[\w]+\.(zip|rar|gz)$/; //|选择符必须用分组符号包含起来 var str = '123.7z'; alert(pattern.test(s ...
- 关于基于webrtc的android-apk 和 webrtc-brows
这一段时间我在做一些关于基于webrtc应用的一些研究,做个一个android的demo,详情如下: 手机客户端: 基于webrtc的 android apk (webrtc 代码版本 R67 ...
- java 1G大文件复制
对比几种复制方法 复制的文件是980m的txt文件 1. FileChannel 方法 代码: public static void mappedBuffer() throws IOExceptio ...
- hdu5681 zxa and wifi
这道题目是不太好想的,尽管很容易看出来应该是dp,但是状态转移总觉得无从下手. 其实我们可以将状态分层,比如设$dp(i, j)$为用$i$个路由器覆盖前$j$个点所需的最小代价 我们先不考虑状态,而 ...
- winform中利用反射实现泛型数据访问对象基类(3)
继续完善了几点代码 满足没有主键的情况下使用 并且完善实体字段反射设置value时的类型转换 /// <summary> /// DAO基类 实体名必须要与数据表字段名一致 /// < ...