# Codeforces.com

/Tag: Codeforces.com

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+06:00April 18th, 2018|Categories: C/C++, Programming||

#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; int ans[maxn]; int p[maxn]; vector<pii>q[maxn]; int main() { int n,m; cin>>n>>m; memset(b,-1,sizeof(b)); p=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+06:00April 18th, 2018|Categories: C/C++, Programming||

#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: (D) Mahmoud and Ehab and another array construction task Solution In C/C++

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

#include<stdio.h> int vi={0}; int main(void) { int n, a, now = 2; int ans; scanf("%d", &n); int flag = 0; int i,j,k; for (i = 1; i <= n; i++) { scanf("%d", &a); ans = now; if (!flag&&a>ans) ans = a; while (vi[ans]) ans++; [...]

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

By |2018-04-18T13:24:16+06:00April 18th, 2018|Categories: C/C++, Programming||

#include<stdio.h> int main(){ int n; scanf("%d",&n); if(n <= 5) printf("-1\n"); else{ printf("1 2\n2 3\n2 4\n"); for(int i = 5;i <= n;i++) printf("1 %d\n",i); } for(int i = 2;i <= n;i++) printf("1 %d\n",i); }

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

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

#include<bits/stdc++.h> using namespace std; map<string,int> ms; string str; int arr,temp,mn; 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+06:00April 18th, 2018|Categories: C/C++, Programming||

#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+06:00November 8th, 2017|Categories: C/C++, Programming||

#include<cstdio> #include<cstring> #include<algorithm> #include<set> using namespace std; int n,k; struct node { int maxx,minn,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+06:00November 8th, 2017|Categories: C/C++, Programming||

#include <stdio.h> struct node { __int64 ans,num; }s; int main() { int n,k,m; while(~scanf("%d%d%d",&n,&k,&m)) { scanf("%I64d",&s.num); s.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+06:00November 8th, 2017|Categories: C/C++, Programming||

#include <iostream> using namespace std; const int maxn = 5e5; int n, x, a = 0, b = 1023, y; 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+06:00November 8th, 2017|Categories: C/C++, Programming||

#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; }