## Codeforces Round #421 (Div. 1), problem: (E) Mister B and Flight to the Moon Solution In C/C++

By |2017-08-05T22:21:39+06:00August 5th, 2017|Categories: C/C++, Programming||

#include<cstdlib> #include<cstdio> #include<algorithm> using namespace std; const int N=301; const int M=100001; const int K=4; int a[M][K]; int f[N]; int n,m,i,j,k,x,y,t,u,v; void make(int &k,int w,int x,int y,int z){ k++; a[k][0]=w; a[k][1]=x; a[k][2]=y; a[k][3]=z; } int main(){ scanf("%d",&n); if(n&1){ f[2]=f[3]=1; }else{ f[1]=3; f[2]=4; f[3]=1; f[4]=2; [...]

## Codeforces Round #421 (Div. 1), problem: (D) Mister B and Astronomers Solution In C/C++

By |2017-08-05T22:19:50+06:00August 5th, 2017|Categories: C/C++, Programming||

#include <bits/stdc++.h> #define ll long long using namespace std; ll n,t,k,i,m,q,f; ll a[200100],s[200100],w[200100],p[200100],res[200100]; map <int,int> mapp; ll cal(ll a,ll b,ll c) { if (c==0) return 0; if (a==0) return -1; ll t=cal(b%a,a,(a-(c%a))%a); if (t==-1) return -1; else return (b*t+c)/a; } ll ucln(ll a,ll b) [...]