# Codeforces Round #422 (Div. 2)

/Tag: Codeforces Round #422 (Div. 2)

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

By |2017-07-25T09:06:25+06:00July 25th, 2017|Categories: C/C++, Programming||

#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[MAXN]; int fa[MAXN], id[MAXN]; db t[MAXN]; void dfs(int u){ db now=t[u], add=2.0/e[u].size(); for(int [...]

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

By |2017-07-25T09:04:16+06:00July 25th, 2017|Categories: C/C++, Programming||

#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[N][35],j,k; ll hs[N],ht[N],q[N]; char s[N],t[N]; inline ll hashs(int l,int r){ return (hs[r]-hs[l-1]*q[r-l+1]%mo+mo)%mo; } inline ll hasht(int l,int r){ return (ht[r]-ht[l-1]*q[r-l+1]%mo+mo)%mo; } inline int lcp(int i,int j){ if(s[i]!=t[j])return 0; l=1; if(m-j<n-i)r=m-j+1; else r=n-i+1; [...]

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

By |2017-07-25T09:02:47+06:00July 25th, 2017|Categories: C/C++, Programming||

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

By |2017-07-25T09:01:08+06:00July 25th, 2017|Categories: C/C++, Programming||

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

## Codeforces Round #422 (Div. 2), problem: (B) Crossword solving Solution In C/C++

By |2017-07-25T08:59:31+06:00July 25th, 2017|Categories: C/C++, Programming||

#include<bits/stdc++.h> using namespace std; int n,m,i,j,c,a=2e9,ai; string s,t; int main(){ cin>>n>>m>>s>>t; for(i=0;i<=m-n;i++) { for(c=j=0;j<n;j++) t[i+j]==s[j]?0:c++; c<a?a=c,ai=i:0; } cout<<a<<endl; for(c=j=0;j<n;j++) t[ai+j]!=s[j]?cout<<j+1<<" ",0:0; }

## Codeforces Round #422 (Div. 2), problem: (A) I’m bored with life Solution In C/C++

By |2017-07-25T08:58:09+06:00July 25th, 2017|Categories: C/C++, Programming||

#include<iostream> using namespace std; int a,b; int main(){ cin>>a>>b; a=a<b?a:b; for(b=a;--a;)b*=a; cout<<b; }