Uva10673-play with floor and ceil (Extended Euclidean theorem)
Actually, it was a very bare question about extending the Euclidean theorem. As a result, floor and ceil were reversed by wa's tragedy.
# Include <cstdio> # include <cstring> # include <algorithm> # include <cmath> using namespace STD; typedef long ll; void ex_gcd (ll a, ll B, ll & D, ll & X, ll & Y) {If (! B) {d = A; X = 1, y = 0; return;} else {ex_gcd (B, A % B, D, Y, X ); y-= x * (a/B); Return ;}} void orz () {int CAS = 0; ll a, B, X, Y, D, C, X, k; scanf ("% d", & CAS); While (CAS --) {scanf ("% LLD", & X, & K ); // A = (LL) Ceil (1.0 * x/K); reverse, wipe // B = (LL) floor (1.0 * x/K ); A = (LL) floor (1.0 * x/K); B = (LL) Ceil (1.0 * x/K); ex_gcd (A, B, D, X, y); X = x * x/d; y = y * x/d; printf ("% LLD \ n", x, y );}} int main () {orz (); Return 0 ;}
Uva10673-play with floor and ceil (Extended Euclidean theorem)