(hdu step 1.3.4)百步穿杨

题目:

百步穿杨

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4043 Accepted Submission(s): 1380
 

Problem Description

时维九月,序属三秋,辽军大举进攻MCA山,战场上两军正交锋.辽军统帅是名噪一时的耶律-James,而MCA方则是派出了传统武将中草药123.双方经过协商,约定在十一月八日正午十分进行射箭对攻战.中草药123早早就开始准备,但是他是武将而不是铁匠,造弓箭的活就交给聪明能干的你了,现在告诉你每种弓箭规格,即箭身的长度,以及每种规格弓箭所需要的数目,要求你把需要的弓箭都输出.
弓箭的基本样子为 ">+---+>",其中"+---+"为箭身,数据保证箭身长度 > 2


Input

首先输入一个t,表示有t组数据,跟着t行:
每行一个N (N < 50 ),接下去有N行,第i行两个整数Ai , Bi,分别代表需要箭身长度为Ai的弓箭Bi枝. (Ai < 30 , Bi < 10 )
输入数据保证每一个Ai都是不同的.


Output

按照箭身的长度从小到大的顺序依次输出所有需要的弓箭,"每一种"弓箭后输出一个空行.


Sample Input

1
4
3 4
4 5
5 6
6 7


Sample Output

>+-+>
>+-+>
>+-+>
>+-+>

>+--+>
>+--+>
>+--+>
>+--+>
>+--+>

>+---+>
>+---+>
>+---+>
>+---+>
>+---+>
>+---+>

>+----+>
>+----+>
>+----+>
>+----+>
>+----+>
>+----+>
>+----+>


Author

Teddy


Source

2008“缤纷下沙校园文化活动月”之大学生程序设计竞赛暨新生专场


Recommend

lcy

题目分析:

大水题,不解释。

代码如下:

/*
 * d.cpp
 *
 *  Created on: 2015年1月29日
 *      Author: Administrator
 */

#include <iostream>
#include <cstdio>

using namespace std;

const int maxn = 55;

/**
 * 打印弓箭
 */
void printArrow(int length, int num) {
	int j;
	for (j = 0; j < num; ++j) {
		printf(">+");
		int i;
		for (i = 0; i < (length - 2); ++i) {
			printf("-");
		}
		printf("+>\n");
	}
//	printf("\n");
}

struct Arrow {
	int length;
	int nums;
} arrow[maxn];

bool cmp(Arrow a, Arrow b) {
	if (a.length < b.length) {
		return true;
	}

	return false;
}

int main() {
	int t;
	scanf("%d", &t);

	while (t--) {
		int n;
		scanf("%d", &n);

		int i;
		for (i = 0; i < n; ++i) {
			scanf("%d%d", &arrow[i].length, &arrow[i].nums);
		}

		sort(arrow, arrow + n, cmp);//注意要对数据先排序...

		for (i = 0; i < n; ++i) {
			printArrow(arrow[i].length, arrow[i].nums);

			printf("\n");
		}

	}

	return 0;
}
时间: 2024-07-28 19:46:12

(hdu step 1.3.4)百步穿杨的相关文章

(hdu step 1.3.8)Who&#39;s in the Middle(排序)

题目: Who's in the Middle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2938 Accepted Submission(s): 1109   Problem Description FJ is surveying his herd to find the most average cow. He wants to k

(hdu step 1.3.1)FatMouse&#39; Trade(在收入需要一定的付出的情况下求最大收入)

题目: FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5092 Accepted Submission(s): 1530   Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats gua

(hdu step 6.1.2)Eddy&#39;s picture(在只给出二维坐标点的情况下,求让n个点连通的最小费用)

题目: Eddy's picture Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 172 Accepted Submission(s): 126   Problem Description Eddy begins to like painting pictures recently ,he is sure of himself to be

(hdu step 5.1.1)A Bug&#39;s Life((ai,bi)表示ai、bi不在同一堆中,有若干对数据,判断是否有bug)

题目: A Bug's Life Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 723 Accepted Submission(s): 277   Problem Description Background Professor Hopper is researching the sexual behavior of a rare spe

(hdu step 3.2.4)FatMouse&#39;s Speed(在第一关键字升序的情况下,根据第二关键字来求最长下降子序列)

在写题解之前给自己打一下广告哈~..抱歉了,希望大家多多支持我在CSDN的视频课程,地址如下: http://edu.csdn.net/course/detail/209 题目: FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1034 Accepted Submission(s): 526   Proble

(hdu step 3.1.5)Tiling_easy version(求用2*1、2*2两种骨格铺满2*n的网格的方案数)

在写题解之前给自己打一下广告哈~..抱歉了,希望大家多多支持我在CSDN的视频课程,地址如下: http://edu.csdn.net/course/detail/209 题目: Tiling_easy version Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 515 Accepted Submission(s): 447   Prob

(hdu step 4.1.5)find the nth digit(求S串中的第n个位置上是什么数字)

题目: find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 689 Accepted Submission(s): 244   Problem Description 假设:S1 = 1S2 = 12S3 = 123S4 = 1234.........S9 = 123456789S10 = 123456789

(hdu step 5.1.3)Segment set(求与一条线段相交的线段集合中的线段的数量)

题目: Segment set Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 177 Accepted Submission(s): 82   Problem Description A segment and all segments which are connected with it compose a segment set. T

(hdu step 2.2.8)N!Again(求N!的阶乘%2009以后的结果)

题目: N!Again Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 941 Accepted Submission(s): 526   Problem Description WhereIsHeroFrom:             Zty, what are you doing ?Zty: