Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solutions to all problems but 1 in contest APRIL16A added. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions codechef/apr18-div1/chefat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

#define rep(i, a, b) \
for (int i = int(a); i < int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
#define mod 1000000007

int main() {
ll t,n,q,i,j,l,r,type;
cin>>n>>q;

double P[q],ans,T;
rep(i,0,n)
{
cin>>P[i];
}
cout<<setprecision(8);
while(q--)
{
ans = 1.0;
cin>>type;
if(type == 0)
{
cin>>l>>r;
rep(i,l-1,r)
ans *= (1-P[i]);
cout<<ans<<"\n";
}
else
{
cin>>l>>r>>T;
rep(i,l-1,r)
P[i] *= T;
}
}


return 0;
}
119 changes: 119 additions & 0 deletions codechef/apr18-div1/chefpar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

#define rep(i, a, b) \
for (int i = int(a); i < int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
#define mod 1000000007
//logarithmic expo
ll power(ll x, ll y)
{
ll val=1;
x = x%mod;
while(y>0)
{
if(y&1)
{
val = (val*x)%mod;
}
y = y>>1;
x = (x*x)%mod;
}
return val;
}
ll spf[1000001];
bool prime[1000001];

void genprime()
{
int i,j;
rep(i,0,1000001)
prime[i] = true;
prime[0] = prime[1] ;
for(i = 2;i<1000001;i++)
{
if(prime[i])
{
for(j = 2*i;j<1000001;j+=i)
{
prime[j] = false;
}
}
}
}

void genspf()
{
spf[1] = 1;int i,j;
for ( i=2; i<1000001; i++)
spf[i] = i;

for ( i=4; i<1000001; i+=2)
spf[i] = 2;

for ( i=3; i*i<1000001; i++)
{
if (spf[i] == i)
{
for ( j=i*i; j<1000001; j+=i)
{
if (spf[j]==j)
spf[j] = i;
}
}
}
/*for(i=1;i<100;i++)
cout<<spf[i]<<" ";*/
}

vector<ll> factorise(ll n)
{
vector<ll> ret,ret1;
while(n!=1)
{
ret.push_back(spf[n]);
n/=spf[n];
}
ret1.push_back(ret[0]);
rep(i,1,ret.size())
{
if(ret[i] != ret[i-1])
ret1.push_back(ret[i]);
}
return ret1;
}

int main() {
ll t,n,i,j,k,m;
cin>>n>>m>>k;
ll A[n], P[m];
rep(i,0,n)
{
cin>>A[i];
}
rep(i,0,m)
{
cin>>P[i];
}
rep(i,0,n)
{
cout<<A[i]+k<<" ";
}


return 0;
}
Loading