• Codeforces Round #657 (Div. 2)B. Dubious Cyrpto


    思路

    题目要求:

    [na+b-c=m ]

    我们可以转换为

    [na-m=c-b ]

    然后(c-b)是固定不变的,我们去枚举a,在枚举的a的时候我们发现要使等式尽可能的成立只有让(na-m)的差值绝对值越小越好,然后我们会发现(na)(m)的左右两侧时,差值绝对值最小。

    比如说

    [2*a……m……3*a ]

    我们让m将在他们中间,此时的差值绝对值是最小的。

    然后枚举(a)即可。

    其中求解左边系数时只有当(i<m)才会有左边的系数。

    因为当(igeq m)时,此时(n)无论取何止都是在(m)的右侧。

    所以我们要分开讨论。

    (|m\%i|)就是左边的差值,(|a-m\%i|)就是右边的差值。然后找最小的可能。

    #include<bits/stdc++.h>
    #define INF 0x3f3f3f3f
    #define DOF 0x7f7f7f7f
    #define endl '
    '
    #define mem(a,b) memset(a,b,sizeof(a))
    #define debug(case,x); cout<<case<<"  : "<<x<<endl;
    #define open freopen("ii.txt","r",stdin)
    #define close freopen("oo.txt","w",stdout)
    #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
    #define pb push_back
    using namespace std;
    //#define int long long
    #define lson rt<<1
    #define rson rt<<1|1
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef pair<long long,long long> PII;
    const int maxn = 1e6 + 10;
    
    
    
    void solve() {
        ll l,r,m;cin>>l>>r>>m;
    
    
        ll lf=l-r,rf=r-l;
    
        for(int i=l;i<=r;++i){
            if(m>i){
                if(m%i<=rf){
                    cout<<i<<" "<<l+m%i<<" "<<l<<endl;break;
                }else if(i-m%i<=rf){
                    cout<<i<<" "<<r-(i-m%i)<<" "<<r<<endl;break;
                }
            }else if(i>=m&&i-m<=rf){
                cout<<i<<" "<<r-i+m<<" "<<r<<endl;
                break;
            }
        }
    
    
    
    }
    
    
    int main() {
        int __;
        cin >> __;
    //    scanf("%d",&__);
        while(__--) {
            solve();
        }
    
    }
    
    

    B. Dubious Cyrpto
    time limit per test1 second
    memory limit per test512 megabytes
    inputstandard input
    outputstandard output
    Pasha loves to send strictly positive integers to his friends. Pasha cares about security, therefore when he wants to send an integer n, he encrypts it in the following way: he picks three integers a, b and c such that l≤a,b,c≤r, and then he computes the encrypted value m=n⋅a+b−c.

    Unfortunately, an adversary intercepted the values l, r and m. Is it possible to recover the original values of a, b and c from this information? More formally, you are asked to find any values of a, b and c such that

    a, b and c are integers,
    l≤a,b,c≤r,
    there exists a strictly positive integer n, such that n⋅a+b−c=m.
    Input
    The first line contains the only integer t (1≤t≤20) — the number of test cases. The following t lines describe one test case each.

    Each test case consists of three integers l, r and m (1≤l≤r≤500000, 1≤m≤1010). The numbers are such that the answer to the problem exists.

    Output
    For each test case output three integers a, b and c such that, l≤a,b,c≤r and there exists a strictly positive integer n such that n⋅a+b−c=m. It is guaranteed that there is at least one possible solution, and you can output any possible combination if there are multiple solutions.

  • 相关阅读:
    通过抓取pintpoint2的页面信息把数据存入数据库python3
    jenkins 2.282+Publish over ssh 1.22版本发布日志不能实时显示
    ELKF搭建
    pinpoint2.0.2 定制开发--增加钉钉群通知、@到具体个人,解决手机号码无法输入BUG、删除客户端需要认证、查看数据日期范围扩大等。
    通过命令行通知RANCHER重新部署程序。
    Jenkins rancher cli 配置
    centos7 outlook mailx配置
    创业公司使用的敏捷GIT FLOW管理方式(多BUG、多项目多环境,多任务并发开发,支持需求多变)
    Dubbo Admin 2.6.2 版本连接zk 集群的连接字符串配置
    jenkins典型配置-多分支选择
  • 原文地址:https://www.cnblogs.com/waryan/p/13374502.html
Copyright © 2020-2023  润新知