Skip to content

Commit

Permalink
CP Season is Back
Browse files Browse the repository at this point in the history
  • Loading branch information
harrypotter0 committed Feb 14, 2018
1 parent 7311e7f commit ece5f55
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
37 changes: 18 additions & 19 deletions CP/ February Challenge 2018/prob4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,37 @@
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define gc getchar_unlocked
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
typedef long long ll;

int main() {
// your code goes here
#ifdef JUDGE
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
#endif
#endif
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--)
{
int n,i;
long double c,d,s;
cin>>n;
long double arr[n],sum=0;
for(i=0;i<n;i++){cin>>arr[i];sum+=arr[i];}
cin>>c>>d>>s;
long double t1=sum,t2=0;
long double wait[n];
wait[0]=arr[0];
long double totwait=0,zero=0,curr=0;
totwait+=wait[0];
for(i=1;i<n;i++)
{
wait[i]=arr[i]-arr[i-1]+ (wait[i-1]<0?wait[i-1]:0);
totwait+=max(wait[i],zero);
}
cout<<fixed<<setprecision(10)<<(c-1)*totwait<<endl;
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
int c,d,s;
cin>>c>>d>>s;
sort(a,a+n);
cout<<prec(10)<<(double)((double)(c-1)*(double)a[n-1])<<"\n";
}

return 0;
}
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions CP/Codemania/prob1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import math
for __ in range(int(input())):
n = int(raw_input())
print(int(math.log(n+1,2))+(1 if math.log(n+1,2)>int(math.log(n+1,2)) else 0))
# print(int(math.log(n+1,2)))
# print(math.log(n+1,2))
Empty file added CP/Codemania/prob2.py
Empty file.
3 changes: 3 additions & 0 deletions CP/Encipher/prob1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
for __ in range(int(input())):
n,m = map(int,raw_input().split())
print(n/m+(1 if n%m>0 else 0))

0 comments on commit ece5f55

Please sign in to comment.