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

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

#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) [...]