Tag: Codeforces.com

Codeforces Round #426 (Div. 2), problem: (C) The Meaningless Game Solution In C/C++

#include <bits/stdc++.h> using namespace std; int main() { ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; long long int a,b,g; cin >> n; while (n–) { cin >>...

Codeforces Round #426 (Div. 2), problem: (B) The Festive Evening Solution In C/C++

#include<cstdio> bool pd; char s; int n,k,size,last; int main(){ scanf(“%d%d%s”,&n,&k,&s); for (int i=0;i<n;++i) last-‘A’]=i; for (int i=0;i<n;++i){ if (!pd-‘A’]) pd-‘A’]=true,++size; if (size>k){ printf(“YES”); return 0; } if (i==last-‘A’]) –size; } printf(“NO”); } 📦 Looking...

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; } 📦 Looking for Codeforces Round 422 Div Problem Pretty? Check...

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; } 📦 Looking for Codeforces...

Codeforces Round #425 (Div. 2), problem: (E) Vasya and Shifts Solution In C/C++

#include<bits/stdc++.h> #define oo 0x3f3f3f3f #define cl(x) memset(x, 0, sizeof(x)) #define mp make_pair #define fr first #define sc second #define pii pair<int, int> #define pb...

Codeforces Round #425 (Div. 2), problem: (D) Misha, Grisha and Underground Solution In C/C++

#include<cstdio> #include<iostream> using namespace std; struct Edge{ int to,next; }e; int head,cnt=0; void add(int u,int v) { cnt++; e.to=v; e.next=head; head=cnt; } int anc; int dep; void dfs(int x,int fa) { for(int i=head;i!=0;i=e.next) { int to=e.to; if(to!=fa) { dep=dep+1; anc=x; dfs(to,x); } } } int lca(int...

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!