打卡信奥刷题(343)用Scratch图形化工具信奥P4670[普及组/提高] [BalticOI 2011 Day2] Plagiarism

[BalticOI 2011 Day2] Plagiarism

题面翻译

Description

世界编程大赛的选手们提交N份程序文件f1, …, fN给评测系统。在将评测结果正式公布之前,评委会想要排除一切可能的剽窃现象。他们已有一个对比程序,用来比较两份程序文件,并判断它们是否太过相似了。 然而程序文件的数目相当大,把每两份(一对,pair)文件都进行比较的话将花太多的时间。另一方面,许多对(pair)可以直接被排除,如果文件的大小相差太大的话。 更准确地说,评委会决定,如果每两份文件(一对,pair)中,较小文件的体积小于较大文件的体积的90%,那将直接不比较这样的一对(pair)。所以,对比程序只比较这样的一对(fi, fj): i≠j, size(fi )≤ size(fj )且size(fi )≥0.9∙size(fj )。 编写程序计算有多少对(pair)文件需要被比较。

Input:

第1行包含一个整数N,即提交的程序文件总数。 第2行包含N个整数size(f1), …, size(fN),每个整数代表文件的体积大小。

Output:

第1行,也是唯一的一行,给出一个整数,即需要被比较的文件的对(pair)的数目。

感谢@谦谦君子 提供翻译

题目描述

The participants of the World Programming Competition submitted N N N solution files f 1 , . . . , f N f_1 ,...,f_N f1,...,fN to the grading system. Before accepting the results as final, the jury would like to rule out any possibility of plagiarism. They have a program that takes two files and compares them to decide if they are too similar to each other.

However, the number of files is rather big and it would take too much time to compare all pairs. On the other hand, many pairs could be quickly eliminated based on the fact that the file sizes are too different.

More precisely, the jury decided to fully skip comparing every pair where the size of the smaller file is less than 90% of the size of the larger one. So, the comparison program has to examine only those distinct pairs of files ( f i , f j ) (f_i, f_j) (fi,fj) where i ≠ j , s i z e ( f i ) ≤ s i z e ( f j ) i≠j, size(f_i) \le size(f_j) i=j,size(fi)size(fj) and s i z e ( f i ) ≥ 0.9 × s i z e ( f j ) size(f_i) \ge 0.9 \times size(f_j) size(fi)0.9×size(fj).

Write a program that computes the number of pairs of files that will have to be examined.

输入格式

The first line of input contains the integer N N N, the number of solution files submitted. The second line contains N N N integers s i z e ( f 1 ) , ⋯   , s i z e ( f N ) size(f_1),\cdots,size(f_N) size(f1),,size(fN), each showing the size of one file.

输出格式

The first and only line of output must contain one integer, the number of pairs of files that will have to be examined.

样例 #1

样例输入 #1

2
2 1

样例输出 #1

0

样例 #2

样例输入 #2

5
1 1 1 1 1

样例输出 #2

10

提示

对于 50 % 50\% 50% 的数据, 1 ≤ N ≤ 2000 1 \le N \le 2000 1N2000

对于所有数据, 1 ≤ N ≤ 1 0 5 , 1 ≤ f i ≤ 1 0 8 1 \le N \le 10^5,1 \le f_i \le 10^8 1N105,1fi108

Scratch实现

在这里插入图片描述

后续

接下来我会不断用scratch来实现信奥比赛中的算法题、Scratch考级编程题实现、白名单赛事考题实现,感兴趣的请关注,我后续将继续分享相关内容

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值