日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

模拟 Codeforces Round #249 (Div. 2) C. Cardiogram

發(fā)布時間:2025/5/22 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?

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

1 /* 2 題意:給一組公式,一組數(shù)據(jù),計算得到一系列的坐標點,畫出折線圖:) 3 模擬題:蠻惡心的,不過也簡單,依據(jù)公式得知折線一定是一上一下的,只要把兩個相鄰的坐標之間的折線填充就好 4 注意:坐標有可能為負數(shù),所以移動值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) //奇數(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坐標 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 }

?

轉(zhuǎn)載于:https://www.cnblogs.com/Running-Time/p/4385027.html

總結(jié)

以上是生活随笔為你收集整理的模拟 Codeforces Round #249 (Div. 2) C. Cardiogram的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。