模拟 Codeforces Round #249 (Div. 2) C. Cardiogram
生活随笔
收集整理的這篇文章主要介紹了
模拟 Codeforces Round #249 (Div. 2) C. Cardiogram
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
題目地址:http://codeforces.com/contest/435/problem/C
1 /* 2 題意:給一組公式,一組數(shù)據(jù),計(jì)算得到一系列的坐標(biāo)點(diǎn),畫出折線圖:) 3 模擬題:蠻惡心的,不過也簡(jiǎn)單,依據(jù)公式得知折線一定是一上一下的,只要把兩個(gè)相鄰的坐標(biāo)之間的折線填充就好 4 注意:坐標(biāo)有可能為負(fù)數(shù),所以移動(dòng)值y初始化為1000,最后要倒過來輸出 5 詳細(xì)解釋: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) //奇數(shù)一定'/' 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 //偶數(shù)一定'\' 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 %d\n", mx, mn); 60 for (int i=mx; i>=mn; --i) //y坐標(biāo) 61 { 62 for (int j=1; j<=tot; ++j) //x坐標(biāo) 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 }?
轉(zhuǎn)載于:https://www.cnblogs.com/Running-Time/p/4385027.html
總結(jié)
以上是生活随笔為你收集整理的模拟 Codeforces Round #249 (Div. 2) C. Cardiogram的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (原)给定输入,输出全排列
- 下一篇: CF510 D - Fox And Ju