【set去重】矩阵中不重复的数

一个m*n的矩阵。
该矩阵的第一列是a^b,(a+1)^b,…..(a + n – 1)^b
第二列是a^(b+1),(a+1)^(b+1),…..(a + n – 1)^(b+1)
…….
第m列是a^(b + m – 1),(a+1)^(b + m – 1),…..(a + n – 1)^(b + m – 1)
(a^b表示a的b次方)
下面是一个4*4的矩阵:
2^2=4, 2^3=8, 2^4=16, 2^5=32
3^2=9, 3^3=27, 3^4=81, 3^5=243
4^2=16, 4^3=64, 4^4=256, 4^5=1024
5^2=25, 5^3=125, 5^4=625, 5^5=3125
问这个矩阵里有多少不重复的数(比如4^3 = 8^2,这样的话就有重复了)
2^2=4, 2^3=8, 2^4=16, 2^5=32
3^2=9, 3^3=27, 3^4=81, 3^5=243
4^2=16, 4^3=64, 4^4=256, 4^5=1024
m = 4, n = 3, a = 2, b = 2。其中2^4与4^2是重复的元素。 继续阅读【set去重】矩阵中不重复的数

【STL二分、打表】因子只包含2 3 5的数

51nod P1010
K的因子中只包含2 3 5。满足条件的前10个数是:2,3,4,5,6,8,9,10,12,15。
所有这样的K组成了一个序列S,现在给出一个数n,求S中 >= 给定数的最小的数。
例如:n = 13,S中 >= 13的最小的数是15,所以输出15。 继续阅读【STL二分、打表】因子只包含2 3 5的数

【STL-MAP】NYOJ 991 Registration system

A new e-mail service “Berlandesk” is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that’s why they ask you to help. You’re suggested to implement the prototype of site registration system. The system should work on the following principle. 继续阅读【STL-MAP】NYOJ 991 Registration system

【优先队列/贪心】The Average

In a speech contest, when a contestant finishes his speech, the judges will then grade his performance. The staff remove the highest grade and the lowest grade and compute the average of the rest as the contestant’s final grade. This is an easy problem because usually there are only several judges.

Let’s consider a generalized form of the problem above. Given n positive integers, remove the greatest n1 ones and the least n2 ones, and compute the average of the rest.

继续阅读【优先队列/贪心】The Average