玩转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 但是实际上任一组整数解即可……也就两种情况……

 

转载于:https://www.cnblogs.com/TO-Asia/p/3219525.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值