Tag: Codeforces Round #422 (Div. 2)

Codeforces Round #422 (Div. 2), problem: (F) Madness Solution In C/C++

#include<cstdio> #include<cstdlib> #include<stdlib.h> #include<iostream> #include<string> #include<string.h> #include<vector> #include<stack> #include<queue> #include<map> #include<cmath> using namespace std; #define pi acos(-1.0) typedef long long ll; typedef double db; const int MAXN = 105; vector<pair<int, int> >e; int fa,...

Codeforces Round #422 (Div. 2), problem: (E) Liar Solution In C/C++

#include<bits/stdc++.h> typedef long long ll; const int N=100010; const ll mo=1000000007; int n,x,i,l,r,m,mid,g,j,k; ll hs,ht,q; char s,t; inline ll hashs(int l,int r){ return (hs-hs*q%mo+mo)%mo; } inline ll...

Codeforces Round #422 (Div. 2), problem: (D) My pretty girl Noora Solution In C/C++

#include<bits/stdc++.h> using namespace std; long long f,pwr,mod=1e9+7,t,r,l,ans; main() { int i,j,k; cin>>t>>l>>r; pwr=1; //for(i=1;i<=r-l+1;i++)pwr=(1ll*pwr*t)%mod; for(i=0;i<=r;i++) f=1e18; f=0; for(i=1;i<=r;i++) { for(j=2*i,k=2;j<=r;j+=i,k++) { f=min(f,(1ll*i*(k-1)*k)/2+f); } } ans=0;long long pr=1; for(i=l;i<=r;i++) ans=(ans+((f)%mod*pr)%mod)%mod,pr=(pr*t)%mod; cout<<ans<<endl; }

Codeforces Round #422 (Div. 2), problem: (C) Hacker, pack your bags Solution In C/C++

#include<cstdio> #include<vector> #include<cstring> #include<algorithm> #define ll long long using namespace std; ll ans,c,n,x,L,R,cc; vector<pair<ll,ll> >l,r; int main(){ scanf("%lld%lld",&n,&x); for(int i=1;i<=n;i++){ scanf("%lld%lld%lld",&L,&R,&cc); l.push_back(make_pair(R-L+1,cc)); r.push_back(make_pair(R-L+1,cc)); } memset(c,0x3f3f,sizeof(c));ans=c; for(int i=1;i<200100;i++){ for(int j=0;j<l.size();j++)l.first>=x?0:ans=min(ans,c.first]+l.second); for(int j=0;j<r.size();j++)c.first]=min(c.first],r.second); } printf("%lld",ans==c?-1:ans); return 0; }

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!