NUIST第一届程序设计大赛团队赛试题

A. 负鼠的追求者

题目描述

负鼠有一个讨厌的追求者,一直紧跟在她后面。

已知负鼠在位置x,它的追求者在位置p,其中1 ≤ p ≤ x。由于负鼠很讨厌这个追求者,所以只有他们所处位置互质的时候,负鼠才能感到舒服。

负鼠的追求者想尽量靠近负鼠,又想让负鼠感到不舒服。所以他只能来请教聪明的你他应该站在什么位置。

输入描述

第一行输入一个整数T(1 ≤ T ≤ 5000),代表测试数据的组数。

接下来的T行,每行包含一个正整数x(1 ≤ x ≤ 5000),表示负鼠所处的位置。

输出描述

对于每一组测试数据,输出一个正整数p,表示追求者应处的位置。

样例输入

1
11

样例输出

10

B. Game

题目描述

One day n cells of some array decided to play the following game. Initially each cell contains a number which is equal to it’s ordinal number (starting from 1). Also each cell determined it’s favourite number. On it’s move i-th cell can exchange it’s value with the value of some other j-th cell, if |i - j| = d[i], where d[i] is a favourite number of i-th cell. Cells make moves in any order, the number of moves is unlimited.

The favourite number of each cell will be given to you. You will also be given a permutation of numbers from 1 to n. You are to determine whether the game could move to this state.

输入描述

The first line contains positive integer T(1  ≤  T  ≤  50), which means the number of test cases.

For each test, the first line contains positive integer n (1  ≤  n  ≤  100) — the number of cells in the array. The second line contains n distinct integers from 1 to n — permutation. The last line contains n integers from 1 to n — favourite numbers of the cells.

输出描述

If the given state is reachable in the described game, output YES, otherwise NO.

样例输入

2
5
5 4 3 2 1
1 1 1 1 1
7
4 3 5 1 2 7 6
4 6 6 1 6 6 1

样例输出

YES
NO

C. 犯困的负鼠

题目描述

负鼠有点犯困了,为了让自己清醒过来,她决定去乡下的小路旁种蒲公英,而我们的问题正是与这些蒲公英有关。

为了简化起见,我们把所有的蒲公英看成一个长度为n的序列(a[1],a[2],…,a[n]),其中a[i]为一个正整数,表示第i棵蒲公英的种类编号。

而每次询问一个区间[l,r],你需要回答区间里出现次数最多的是哪种蒲公英,如果有若干种蒲公英出现次数相同,则输出种类编号最小的那个。

注意,你的算法必须是在线的。

输入描述

第一行两个整数 n,m ,表示有 n 株蒲公英, m 次询问。

接下来一行 n 个空格分隔的整数a[i] ,表示蒲公英的种类。

再接下来 m 行每行两个整数 l[0],r[0] ,我们令上次询问的结果为 x(如果这是第一次询问,则x=0)。

令l=(l[0]+x-1)mod n + 1,r=(r[0]+x-1) mod n +1,,如果l>r ,则交换l,r,最终的询问区间为[l,r]。

保证1 ≤ n ≤ 40000 ,1 ≤ m ≤ 50000 , 1 ≤ a[i] ≤ 10^9 。

注意:本题仅有一组测试数据

输出描述

输出 m 行。每行一个整数,表示每次询问的结果。

样例输入

6 3
1 2 3 2 1 2
1 5
3 6
1 5 

样例输出

1
2
1

D. 天天爱跑步

题目描述

syf和cjy想去进行跑步比赛。于是他们找到了一条长度为L的跑道(直的),但是跑道的末端有一个大黑洞,跑过去的人会被黑洞吞噬。

已知syf一步能跑的距离为w,cjy一步能跑的距离为b,他们会跑的尽量远,但是不会超过跑道的末端。现在规定跑的远的获胜。

举个例子,当L=7,w=3,b=4时,syf能跑到位置6(2步),cjy能跑到位置4(1步),他们两个任何一个人再多跑一步都会掉进黑洞。此时syf获胜,因为他跑的更远。

由于黑洞的扩大,跑道出现了变小的情况。跑道长度L会变成[1,L]中的任意一个值,现在请聪明的你帮他们算算,平局的概率为多少。

输入描述

第一行输入一个整数T(1 ≤ T ≤ 100),代表测试数据的组数。

接下来的T行,每行输入三个整数L,w,b,分别表示跑道的初始长度L,syf一步能跑的距离,cjy一步能跑的距离,其中1  ≤  t, w, b  ≤  5*10^18。

输出描述

每行输出一个分数形式p/q。表示两人平局的概率,要求p/q是最简真分数。

样例输入

2
10 3 2
7 1 2

样例输出

3/10
3/7

E. 愉快的负鼠

题目描述

今天负鼠心情不错,就开始数数。当一个数不能被2~10中任意一个数整除时,负鼠认为这个数是一个幸运数。

现在负鼠想知道,如果给定一个n,那么1~n中有多少个数是幸运数呢。

输入描述

第一行输入一个整数T(1 ≤ T ≤ 100),代表测试数据的组数。

接下来的T行,每行包含一个正整数n(1 ≤ n ≤ 10^18)。

输出描述

每行输出一个数,表示1~n中幸运数的个数。

样例输入

1
12

样例输出

2

F. Relative Molecular Mass

题目描述

With the given relative atomic mass, calculate the relative molecular mass.
Using simplest dot to represent middle-aligned dot in formula.

输入描述

Single group of test cases.

The first line is two integer n, m. (1 ≤ n ≤ 118, 1 ≤ m ≤ 100)
Next n lines, each line contains a string and a float number. Indicates the atom and the relative atomic mass.

Next m lines, each line contains a formula with atom given before. Strings contain only letters, numbers, dots and parentheses ‘()’. No square brackets.

输出描述

Print m lines, each line contains an integer, which means the relative molecular mass rounded to integer.

Data promises that there will not be a result with the first decimal place being 5 before round. (Like 316.51)

No fabricate atom

样例输入

5 3
H 1.00794
C 12.0107
O 15.9994
Cu 63.546
S 32.065
CH4
CH3(CH2)4CH3
CuSO4.5H2O
样例输出
16
86
250

G. 后勤部长的晚会

题目描述

syf公司和cjy公司举办了一次联谊晚会。晚会上,syf公司的N位员工和cjy公司的M位员工打算进行一场交际舞。在这些领导中,一些syf公司的员工和cjy公司的员工之间是互相认识的,这样的认识关系一共有T对。舞会上,每位员工会尝试选择一名Ta认识的对方公司的员工作为舞伴,并且每位员工至多跳一支舞。完成的交际舞的数量越多,晚会的气氛就越热烈。顾及到晚会的气氛,员工们希望知道,哪些员工之间如果进行了交际舞,就会使整场晚会能够完成的交际舞的最大数量减小。

输入描述

第一行三个整数N, M, T。(1 ≤ N,M ≤ 10000,1 ≤ T ≤ 100000,1 ≤ x ≤ N,1 ≤ y ≤ M)

接下来T行每行两个整数x、y,表示syf公司的员工x和cjy公司的员工y互相认识。

注意,本题仅有一组测试数据

输出描述

第一行一个整数cnt,表示进行了交际舞后会使整场晚会能够完成的交际舞的最大数量减小的员工有多少对。
第二行cnt个整数,升序输出这样的一对员工的认识关系的编号(他们的认识关系是在输入数据中读入的第几条认识关系)。如果cnt=0,输出一个空行。

样本输入

3 3 6
1 1
2 1
2 2
3 1
3 2
3 3
样本输出
3
2 4 5

H.摸鱼1

题目描述

众所周知,摸鱼是一种令人羡慕的生活方式。sbw养了一池子鱼,对第i条鱼,一开始重量为w[i],并且每天会变重a[i]。现在有一笔订单,总共要购买重量总和不少于S的鱼。因为这个鱼是要拿去东苑三楼做烤鱼的,所以要求卖出去的每条鱼的重量至少为W,否则太小了的话顾客会感到不满意。sbw想知道他至少要养多少天鱼才能交货。

输入描述

第一行一个数字 T (T ≤ 10), 表示有 T 组输入数据。

每组输入数据先输入三个整数 n, S, W, 其中 1 ≤ n ≤ 10^6, 1 ≤ S,W ≤ 10^12。

接下来两行,第一行输入n个整数w[i],第二行输入n个整数a[i]。

其中 1 ≤ w[i],a[i] ≤ 10^9。

输出描述

一个整数,表示最少所要的天数。

样例输入

1
3 74 51
2 5 2
2 7 9

样例输出

7

I. 摸鱼2

题目描述

sbw 把自己家的鱼塘画成了网格状,形成了一个 n × m 的矩形。因为他的鱼都非常非常暴躁,所以他们不愿意生活在在一排或者一列上。sbw 想知道他总共有多少种养鱼方法 (可以一条都不养)。

输入描述

第一行一个数字 T (T ≤ 10), 表示有 T 组输入数据。

每组输入数据输入两个整数 n, m,表示鱼塘的行和列

其中 1 ≤ n , m ≤ 2 × 10^3

输出描述

一个整数,表示养鱼的方法数量。(结果可能非常大,所以对 10005 取模)。

样例输入

2
1 10
2 2

样例输出

11
7

J. ytF’s cupboard

题目描述

A girl named ytF has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius r (the cupboard’s top) and two walls of height h (the cupboard’s sides). The cupboard’s depth is r, that is, it looks like a rectangle with base r and height h + r from the sides. The figure below shows what the cupboard looks like (the front view is on the left, the side view is on the right).

ytF got lots of balloons for her birthday. The girl hates the mess, so she wants to store the balloons in the cupboard. Luckily, each balloon is a sphere with radius r/2. Help ytF calculate the maximum number of balloons she can put in her cupboard.

You can say that a balloon is in the cupboard if you can’t see any part of the balloon on the left or right view. The balloons in the cupboard can touch each other. It is not allowed to squeeze the balloons or deform them in any way. You can assume that the cupboard’s walls are negligibly thin.

输入描述

The single line contains two integers r, h (1  ≤  r, h  ≤  10^7).

输出描述

Print a single integer — the maximum number of balloons ytF can put in the cupboard.

样例输入

3
1 1
1 2
2 1

样例输出

3
5
2

K. 打牌

题目描述

负鼠最近迷上了一款卡牌游戏,于是她就叫来了她的男朋鼠跟她一起玩(就是A题那个追求者)。

游戏规则是这样的:开局时他们一共能得到6张牌,每张牌上有一个咕值x,负鼠和她的男朋鼠各得到3张牌,三张牌的咕值加起来即为总咕值,总咕值高的一方取胜。

负鼠的男朋鼠为了哄她,想要尽量不让她输,但出于自尊心,他自己也不想输。于是,平局(双方咕值相同)就成了最好的选择。

现在已知这6张牌每张的咕值。如果双方能达成平局输出"YES",否则输出"NO"。

输入描述

第一行输入一个整数T(1 ≤ T ≤ 100),代表测试数据的组数。

接下来的T行,每行包含六个正整数,每个数的范围为[0,1000],表示每张牌的咕值大小。

输出描述

如果能达成平局,输出YES,否则输出NO(注意大小写)

样例输入

2
1 3 2 1 2 1
1 1 1 1 1 99

样例输出

YES
NO
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

总想玩世不恭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值