Problem Statement
Definition
- Class:
- ArithmeticalMean
- Method:
- howMany
- Parameters:
- int[], int, int
- Returns:
- long
- Method signature:
- long howMany(int[] elements, int L, int H)
- (be sure your method is public)
Constraints
- elements will contain between 1 and 36 elements, inclusive.
- Each element of elements will be between -25000000 and 25000000, inclusive.
- Each element of elements will be distinct.
- L and H will each be between -25000000 and 25000000, inclusive.
- L will not be greater than H.
Examples
{10,1,3}
2
6
Returns: 4
All possible arithmetic means are: 1, 2, 3, 14/3, 11/2, 13/2, 10. Four of them (2, 3, 14/2, 11/2) make "good" subsets.
{0}
-1
0
Returns: 1
There is just one subset and it's "good".
{0}
100
100
Returns: 0
Same one subset but it's not "good".
{1,2,3,4,5,6,7,8,9,10}
3
7
Returns: 949
{6221024,-19453578,3228809,17095944,-22901268}
-14978761
-4772239
Returns: 9
{5074630,-50090,22053906,-11588424,-2113083,-11308758,-2685639,13254301,18660208,-5356855,-16063340,12857449,10022876,22634490}
4833654
6995429
Returns: 3391
{-14630882,-16405758,-8752661,14799116,-15265895,-13487269,24539951,15925138,19489573,-15030418,-14514529}
-3894878
21236449
Returns: 1298
{21821170,-18467821,8190162,17602659,-14182401,-2147638,1315230,-9981315,-22299231,-14468553,-22732935,-11238918,22334722,-6659673,-10346451,18136346,10087381,4795874,1945271,12428579,-15464977,-13941724,23837225,2082963,-4745366,9267837,24807767,15875560,-19452091,-24460042,-4031407,24538189,7440641,24337103,-6200520,-6192869}
-21073933
8846229
Returns: 68595990866
{2024234,22921985,7746458,-5405187,10203328,-3736305,-14925110,-23720275,3558456,-13723869,-5759011,-17770581,6900968,-14050846,-17640409,-3654285,18878162,21710166,-14977712,1359516,14509288,12979157,8447692,11457144,17692271,-18422721,10899283,1244575}
4638096
17868469
Returns: 18152893
{-5389993,-21253455,-17206933,6673449,-9042734,-17498776,-18077938,5414765,6737350,4728168,24484307,-661772,1788925,6522554,12964969,23416068,1205056,2009383,-1212604,-23743285,-7013588,-6515528,-7606931,-7620406,-1209840,22033958,714141,1452786,-20506674,-7773930}
-14090732
-9914177
Returns: 681275
{-16830934,-19537724,182862,8723043,-18067048,17141305,-15454064,18727682,-10349466,-22058612,18308387,-20144057,24401179,-15112232,7238502,-13340287,24996556,-199968,-13259622,-14809758,4346735,-12002437,24756148,9384259,-9234279,21702250,23154522,9881714,-18564796,-5767794,23074425,2618921,-5254743,-21419728,-17807555,-22959159}
-21548291
20901841
Returns: 68719476229
{3991894,13053700,10018606,14755819,8671806,-4766120,4617541,5215275,-6833961,3055034,-7700571,-4363841,981967,-1036302,-2654716,5165235,4061907,11213938,-8762154,-20221777,12594523,-20200638,6696622,-15670027,-5359323,1457392,-2925759,21411272,-20207511,-5160452,-3417102,4356047,-16415649,19441507,-680375,24242713}
-2981412
3677559
Returns: 62236478100
{22634685,-3595464,20596862,-22534278,-194336,6280916,-978278,9482555,-17258848,2158338,19125531,-12830940,24930919,21492970,5725742,9795619,-13857613,17699573,-13715651,4113115,-15165420,-5903794,20006397,16720497,-5629115,6843069,21909191,-18714159,13499403,-10780765,-6419032,19214691,4069619,12081026,-15152232,-5140598}
1454161
7845775
Returns: 50009196861
{0 }
-1
0
Returns: 1
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
3
7
Returns: 949
{-13859313, -3095719, -11176973, 7224396, 23205935, -16088130, -12868680, 7158557, 4586733, -15578527, -17933107, 15545020, 5179790, -5625015, 6849604, 3511665, 10953648, 6305415, -24759122, 3785153, 21708672, 17087313, 7479920, 12437039, 12297103, 3029164, -11302060, 4913084, -21146222, -3823611, 12766291, -6710512, 3280088, 21102141, -5224066, 12578275 }
-1000000
1000000
Returns: 19613297287
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 }
7
27
Returns: 68718305835
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 24, 26, 27, 28, 29, 30 }
-30000
30000
Returns: 1073741823