我是靠谱客的博主 甜美摩托,最近开发中收集的这篇文章主要介绍模拟 Codeforces Round #249 (Div. 2) C. Cardiogram,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

 

题目地址:http://codeforces.com/contest/435/problem/C

 1 /*
 2 
题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:)
 3 
模拟题:蛮恶心的,不过也简单,依据公式得知折线一定是一上一下的,只要把两个相邻的坐标之间的折线填充就好
 4 
注意:坐标有可能为负数,所以移动值y初始化为1000,最后要倒过来输出
 5 
详细解释:http://blog.csdn.net/zhb1997/article/details/27877783
 6 */
 7 #include <cstdio>
 8 #include <iostream>
 9 #include <algorithm>
10 #include <cstring>
11 #include <string>
12 #include <cmath>
13 #include <set>
14 using namespace std;
15
16 const int MAXN = 1e3 + 10;
17 const int INF = 0x3f3f3f3f;
18 int map[MAXN<<1][MAXN<<1];
19 int a[MAXN];
20
21 int main(void)
//Codeforces Round #249 (Div. 2) C. Cardiogram
22 {
23
//freopen ("G.in", "r", stdin);
24
25
int n;
26
while (~scanf ("%d", &n))
27 
{
28
int tot = 0;
int mx = 1000, mn = 1000, x = 0, y = 1000;
29
for (int i=1; i<=n; ++i)
scanf ("%d", &a[i]), tot += a[i];
30
31
memset (map, 0, sizeof (map));
32
for (int i=1; i<=n; ++i)
33 
{
34
x++;
35
if (i & 1)
//奇数一定'/'
36 
{
37
a[i]--;
38
map[y][x] = 1;
39
while (a[i]--)
40 
{
41
x++;
y++;
42
map[y][x] = 1;
43 
}
44
mx = max (mx, y);
45 
}
46
else
//偶数一定''
47 
{
48
a[i]--;
49
map[y][x] = 2;
50
while (a[i]--)
51 
{
52
x++;
y--;
53
map[y][x] = 2;
54 
}
55
mn = min (mn, y);
56 
}
57 
}
58
59
//printf ("%d %dn", mx, mn);
60
for (int i=mx; i>=mn; --i)
//y坐标
61 
{
62
for (int j=1; j<=tot; ++j)
//x坐标
63 
{
64
if (map[i][j] == 1)
printf ("/");
65
else if (map[i][j] == 2)
printf ("\");
66
else
printf (" ");
67 
}
68
puts ("");
69 
}
70 
}
71
72
return 0;
73 }

 

转载于:https://www.cnblogs.com/Running-Time/p/4385027.html

最后

以上就是甜美摩托为你收集整理的模拟 Codeforces Round #249 (Div. 2) C. Cardiogram的全部内容,希望文章能够帮你解决模拟 Codeforces Round #249 (Div. 2) C. Cardiogram所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部