玩转Floor 和 Ceil (Play with Floor and Ceil,UVa 10673)

 1 #include <iostream>
 2 #include <string.h>
 3 #include <string>
 4 #include <fstream>
 5 #include <algorithm>
 6 #include <stdio.h>
 7 #include <vector>
 8 #include <queue>
 9 #include <set>
10 #include <cmath>
11 using namespace std;
12 const double eps = 1e-8;
13 const double pi=acos(-1.0);
14 const int INF=0x7fffffff;
15 unsigned long long uINF = ~0LL;
16 #define MAXN 1007
17 #define mod 1000000007
18 typedef long long LL;
19 //ax+by=d;
20 void gcd(LL a,LL b,LL& d,LL& x,LL& y)
21 {
22     if(!b){d=a;x=1;y=0;}
23     else {gcd(b,a%b,d,y,x);y-=x*(a/b);}
24 }
25 int main()
26 {
27     int T;
28     LL x,k;
29     scanf("%d",&T);
30     while(T--)
31     {
32         scanf("%lld%lld",&x,&k);
33         if(x%k==0)
34         printf("0 %lld\n",k);
35         else printf("%lld %lld\n",-x,x);
36     }
37 
38     return 0;
39 }

说是扩展gcd 但是实际上任一组整数解即可……也就两种情况……

 

posted @ 2013-07-27 15:08  TO_Asia  阅读(274)  评论(0编辑  收藏  举报