Codeforces Round #657 (Div. 2) B. Dubious Cyrpto(思维,数学)
程序员文章站
2022-03-12 19:28:59
题目链接题意:m=n⋅a+b−c(n为任意正整数),给出m的值a,b,c的范围l,r(l<=a,b,c<=r),求出a,b,c。思路:由推倒知0<=|b-c|<=r-l,然后枚举看能否有m%a或者a-m%a能够>=0或<=r-l即可。代码:#includeusing namespace std;#define int long long#define IOS ios::sync_with_stdio(false)...
题目链接
题意:
m=n⋅a+b−c(n为任意正整数),给出m的值a,b,c的范围l,r(l<=a,b,c<=r),求出a,b,c。
思路:
由推倒知0<=|b-c|<=r-l,然后枚举看能否有m%a或者a-m%a能够>=0或<=r-l即可。
代码:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=2e5+7;
const double eps=1e-8;
const int mod=1e9+7;
const int inf=0x7fffffff;
const double pi=3.1415926535;
signed main()
{
IOS;
int t;
cin>>t;
while(t--)
{
int a,b,m;
cin>>a>>b>>m;
for(int i=a;i<=b;i++)
{
int ret=m%i,op=m/i;
int res=i-ret;
if(ret<=b-a&&op)
{
cout<<i<<" "<<a+ret<<" "<<a<<endl;
break;
}
else if(res<=b-a)
{
cout<<i<<" "<<b-res<<" "<<b<<endl;break;
}
}
}
return 0;
}
本文地址:https://blog.csdn.net/ACkingdom/article/details/107472292
上一篇: JavaWeb http协议的自我描述
下一篇: php Memcache 中实现消息队列
推荐阅读
-
Codeforces Round #649 (Div. 2)-B. Most socially-distanced subsequence(思维)
-
B. Power Sequence(数学+枚举)Codeforces Round #666 (Div. 2)
-
Codeforces Round #657 (Div. 2) B. Dubious Cyrpto(思维,数学)
-
Codeforces Round #489 (Div. 2) B. Nastya Studies Informatics(数学+枚举优化)
-
Codeforces Round #673 (Div. 2) B. Two Arrays(思维,构造)
-
B. Two Arrays(模拟+思维)Codeforces Round #673 (Div. 2)
-
B. Jzzhu and Sequences(思维)Codeforces Round #257 (Div. 2)
-
Codeforces Round #621 (Div. 1 + Div. 2) B. Cow and Friend (思维)
-
B. RPG Protagonist[Educational Codeforces Round 94 (Rated for Div. 2)]数学枚举
-
Codeforces Round #649 (Div. 2)-B. Most socially-distanced subsequence(思维)