https://codeforces.com/contest/1379/problem/B
题意:
给定l,r,m
要求构造出一组a,b,c,满足:
l<=a,b,c<=r,存在一个正整数n,n*a+b-c=m
数据范围:1<=l,r<=5e^5,1<=m<=1e10
题解:
对等式变换可知:n=(m+c-b)/a; 我们可知c-b的范围是[l-r,r-l];(这里很重要。。。我陷入误区:误认为[0,r-l],一直wrong);
枚举a,要确定n是正整数,那么可知c-b不是a-m%a,就是-m%a,然后我们确定这两个数是不是在[l-r,r-l]内,若在直接输出.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int maxn=1e5+5;
void io() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); }
int main() {
int test; scanf("%d",&test);
while(test--) {
ll m,l,r,a,b,c;
scanf("%lld%lld%lld",&l,&r,&m);
ll mx=r-l,mi=l-r;
for(a=l;a<=r;++a) {
ll x=m%a;
ll y=a-x;
if(y<=mx) {
b=l;c=l+y;break;
} else if(-x>=mi) {
b=r;c=r-x; break;
}
}
printf("%lld %lld %lld\n",a,b,c);
}
return 0;
}