产生学号山科c语言oj,c语言 山科大OJ

该博客讨论了一道计算机科学题目,涉及到寻找两个数列的最长公共子序列。题目给出了每个序列的长度、起始元素和增量值,并要求在不超过1,000,000的范围内找到共有的元素。输入包括多个测试用例,需要计算并输出最长公共子序列的长度。博客中还包含了网友的讨论和解答。
摘要由CSDN通过智能技术生成

c语言 山科大OJ

关注:252  答案:2  手机版

解决时间 2021-02-05 03:05

提问者更无风月

2021-02-04 05:44

Description

LCS stands for longest common subsequence, and it is a well known problem. A sequence in this problem means a list of integers, and a sequence X is considered a subsequence of another sequence Y, when the sequence X can be obtained by deleting zero or more elements from the sequence Y without changing the order of the remaining elements.

In this problem you are given two sequences and your task is to find the length of the longest sequence which is a subsequence of both the given sequences.

You are not given the sequences themselves. For each sequence you are given three integers N, F and D, where N is the length of the sequence, F is the first element in the sequence. Each element except the first element is greater than the element before it by D.

For example N= 5, F= 3 and D= 4 represents the following sequence: [3, 7, 11, 15, 19].

There will be at least one integer which belongs to both sequences and it is not greater than 1,000,000.

Input

Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1<=T<=100). Followed by the test cases, each test case is described in one line which contains 6 integers separated by a single spaceN1 F1 D1 N2 F2 D2(1<=N1,N2<= 10^18) and (1<=F1,D1,F2,D2<=10^9) representing the length of the first sequence, the first element in the first sequence, the incremental value of the first sequence, the length of the second sequence, the first element in the second sequence and the incremental value of the second sequence, respectively.

Output

For each test case, print a single line which contains a single integer representing the length of the longest common subsequence between the given two sequences.

Sample Input

35 3 4 15 3 110 2 2 7 3 3100 1 1 100 1 2

Sample Output

4350

求答案

最佳答案

二级知识专家我心里的你没人能代替

2021-02-04 06:07

苦了山科大的学生了,我们原来还没有英语的题目,现在真是高大尚了

全部回答

1楼空虚的心

2021-02-04 07:01

可以使用结构体数组,数组大小为101 x sizeof(结构体):

具体数据结构如下:

typedef struct stscore

{

unsigned short usscore; //得分

unsigned short uscount; //得usscore分数的人次}score;

}

//得分、以及相因得分人数的结构体数组定义

score stascorecount[101];

数组下表0-100即为得分。每统计到一个得分,就在相应的数组成员的uscount上加一,最后对数组按人数排序即可。

我要举报

如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!

推荐资讯

大家都在看

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值