This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() { | |
int i = 0,m = 0, left; | |
double minx[left], ppl[left], res; | |
double d1 = 5, d2 = 10; | |
scanf("%d",&left); | |
for(i=0;i<left;i++){ | |
scanf("%lf",&ppl[i]); | |
minx[i] = 0; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = Array.new | |
b = Array.new | |
gets.chomp.to_i.times do | |
a << gets.chomp.to_i | |
end | |
a.sort!{|x,y| x <=> y} | |
while gets != "###" do | |
gets.chomp.to_i.times do | |
b << a[gets.chomp.to_i-1] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i = gets.chomp.to_i | |
input = gets.split().map(&:to_i).sort | |
sum = 0 | |
positive = 0 | |
input.each do |inp| | |
m = 0 | |
while(m/inp.to_f <= 0.5 && positive/i.to_f <= 0.5) do | |
m = m + 1 | |
end | |
positive = positive + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a, b = Array.new, Array.new | |
total = 0 | |
gets.to_i.times do | |
a << gets.to_i | |
end | |
gets.to_i.times do | |
b << gets.to_i | |
end | |
b.each do |date| | |
a.include?(date)? (total = total + 1):(total) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
range_inp = gets.split().map(&:to_i) | |
x = gets.chomp.to_i | |
l = range_inp[0] | |
r = range_inp[1] | |
m = (r - l)*0.5+l | |
(x <= midpoint)? (range = (l..m)):(range = (m..r)) | |
enum = 0 | |
range.to_a.each do |y| | |
if y == x | |
enum = enum + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# basic sample | |
sample_array = Array.new | |
i, t = 0, 0 | |
# puts "what is the size of array?" | |
limit = 50 #gets.chomp.to_i | |
#puts "what is the maximum size of identical numbers set?" | |
max_rand = 15 #gets.chomp.to_i | |
#puts "what do you want to find X, [L..R]? Input x l r!!!" | |
#xlr = gets.split().map(&:to_i) | |
l,r = 0, 50 #xlr[0],xlr[1],xlr[2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
restart; | |
with(Statistics): | |
STDNORM:=proc( ) local ij,U1,U2,S,B,X1;global i,X2; | |
if type(i,boolean)then | |
if (i) then | |
i:=not(i);X2; | |
else | |
for ij from 1 to infinity do | |
U1:=evalf(2.0*rand()/10^12)-1.0; | |
U2:=evalf(2.0*rand()/10^12)-1.0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sorted_array_shifter(length, n) | |
random_array = (1..length).to_a.inject(Array.new) do |arr, el| | |
el = rand(1..el); arr << el; | |
end | |
array = random_array.sort {|x,y| y<=>x } | |
n.times do | |
array.shift | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def heap_extractor(length, n) | |
random_array = (1..length).to_a.inject(Array.new) {|arr, el| el = rand(1..el); arr << el;} | |
array = HeapModule.build_max_heap(random_array) | |
n.times do | |
HeapModule.extract_maximum(array) | |
end | |
end |
OlderNewer