Codeforces Solution, Codeforces.com solution,codeforces div 1 solution, codeforces division 1 solution,codeforces div 2 solution, codeforces division 2 solution,Codeforces problem,codeforcesproblem solution,codeforces regular problem solution,codeforces regular,c programming sample programms, c programming examples,c++ regular programms, c++ programming examples,programmng language , basic programming,easy programming example,easy programming solutions,C language, c language solutions, c language examples,Codeforces solve, Codeforces.com solve,codeforces div 1 solve, codeforces division 1 solve,codeforces div 2 solve, codeforces division 2 solve,Codeforces problem,codeforcesproblem solve,codeforces regular problem solve,codeforces regular,c programming sample programms, c programming examples,c++ regular programms, c++ programming examples,programmng language , basic programming,easy programming example,easy programming solves,C language, c language solves, c language examples,

Codeforces Round #473 (Div. 2), problem: (F) Mahmoud and Ehab and yet another xor task Solution In C/C++

By |2018-04-18T13:41:56+00:00April 18th, 2018|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include<bits/stdc++.h> #define LL long long using namespace std; const int maxn = 1e5+5; const int mod =1e9+7; typedef pair<int,int>pii; int a[maxn]; int b[25]; int ans[maxn]; int p[maxn]; vector<pii>q[maxn]; int main() { int n,m; cin>>n>>m; memset(b,-1,sizeof(b)); p[0]=1; for(int i=1;i<=n;i++)scanf("%d",&a[i]),p[i]=p[i-1]*2%mod; for(int i=1;i<=m;i++) { int l,x; scanf("%d%d",&l,&x); [...]

Codeforces Round #473 (Div. 2), problem: (E) Mahmoud and Ehab and the xor-MST Solution In C/C++

By |2018-04-18T13:34:59+00:00April 18th, 2018|Categories: C/C++, Programming|Tags: , , , , , , |

#include <stdio.h> long long n,res,a=1; int main() { for (scanf("%I64d",&n);a<n;res+=(n-1)/a*(a-(a>>1)),a<<=1ll); printf("%I64d\n",res); return 0; }

Codeforces Round #473 (Div. 2), problem: (B) Mahmoud and Ehab and the message Solution In C/C++

By |2018-04-18T13:14:02+00:00April 18th, 2018|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include<bits/stdc++.h> using namespace std; map<string,int> ms; string str; int arr[100005],temp[100005],mn[100005]; int main() { int n,k,m;cin>>n>>k>>m; for(int i=1;i<=n;i++)cin>>str,ms[str]=i; for(int i=1;i<=n;i++)cin>>arr[i],mn[i]=1e9+7; for(int i=1,j;i<=k;i++) { int x;cin>>x; while(x--)cin>>j,temp[j]=i,mn[i]=min(mn[i],arr[j]); } unsigned long long res=0; while(cin>>str){res+=mn[temp[ms[str]]];} return cout<<res<<"\n",0; }

Codeforces Round #473 (Div. 2), problem: (A) Mahmoud and Ehab and the even-odd game Solution In C/C++

By |2018-04-18T13:09:29+00:00April 18th, 2018|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <stdio.h> int main() { int N; scanf("%d", &N), puts(N&1 ? "Ehab" : "Mahmoud"); }

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

By |2017-11-08T09:27:59+00:00November 8th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include<cstdio> #include<cstring> #include<algorithm> #include<set> using namespace std; int n,k; struct node { int maxx[15],minn[15],sz; node() { int x;sz = 1; for(int i = 1; i <= k ; i ++) { scanf("%d",&x); minn[i] = maxx[i] = x; } } bool operator<(const node &nd)const { [...]

Codeforces Round #443 (Div. 2), problem: (D) Teams Formation Solution In C/C++

By |2017-11-08T09:26:00+00:00November 8th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <stdio.h> struct node { __int64 ans,num; }s[101000]; int main() { int n,k,m; while(~scanf("%d%d%d",&n,&k,&m)) { scanf("%I64d",&s[0].num); s[0].ans=1; int len=1; for(int i=1;i<n;i++) { int x; scanf("%d",&x); if(x==s[len-1].num) { s[len-1].ans++; if(s[len-1].ans==k) { s[len-1].ans=0; len--; } } else { s[len].num=x; s[len].ans=1; len++; } } int l=0,r=len-1; __int64 [...]

Codeforces Round #443 (Div. 2), problem: (C) Short Program Solution In C/C++

By |2017-11-08T09:24:01+00:00November 8th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <iostream> using namespace std; const int maxn = 5e5; int n, x, a = 0, b = 1023, y[3]; char c; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> c >> x; if [...]

Codeforces Round #443 (Div. 2), problem: (A) Borya’s Diagnosis Solution In C/C++

By |2017-11-08T09:19:12+00:00November 8th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<bits/stdc++.h> using namespace std; int main() { int n,i,s,d,t=0; cin>>n; for(i=0;i<n;i++) { cin>>s>>d; while(s<=t) { s=s+d; } t=s; } cout<<s<<endl; }

Codeforces Round #444 (Div. 2), problem: (F) Row of Models Solution In C/C++

By |2017-11-07T20:11:01+00:00November 7th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include<bits/stdc++.h> #define maxn 1000050 using namespace std; int a[maxn],b[maxn],c[maxn],n,k,m,t; int main() { scanf("%d%d",&n,&k); for (int i=0;i<n;i++) scanf("%d",&a[i]); a[n]=0; memset(c,-1,sizeof(c)); m=0;b[m]=0;c[0]=0;t=0; for (int i=1;i<=n;i++) if (a[i]<a[b[m]]) b[++m]=i,c[i]=m; for (int i=1;i<=m;i++) if (b[i]-b[i-1]>2*k) {puts("NO");return 0;} else if (b[i]-b[i-1]>k) { if (t) {puts("NO");return 0;} else t=i; } [...]

Codeforces Round #444 (Div. 2), problem: (E) Little Brother Solution In C/C++

By |2017-11-07T20:08:13+00:00November 7th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> #include<cstdlib> #define eps 1e-7 using namespace std; double x[100010],y[100010],r[100010],L; struct node{double l,r;}a[100010]; struct P{double x,y;}A,B,M,s,O,p[100010]; int n; inline double dis(P a,P b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));} inline P operator-(P a,P b){return (P){a.x-b.x,a.y-b.y};} inline double operator*(P a,P b){return a.x*b.y-a.y*b.x;} inline bool cmp(node [...]