1379B - Dubious Cyrpto - CodeForces Solution


binary search brute force math number theory *1500

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
template<typename... T>
void see(T&... args) { ((cin >> args), ...);}
template<typename... T>
void put(T&&... args) { ((cout << args << " "), ...);}
template<typename... T>
void putl(T&&... args) { ((cout << args << " "), ...); cout<<'\n';}
#define error(args...) { string _s = #args; replace(_s.begin(),     _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << "=" << a << ", "; err(++it, args...);}
// #define int long long
#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define vl vector<ll>
#define vll vector<pll>
#define vc vector
#define mii map<int,int>
#define mll map<ll,ll>
#define mli map<ll,int>
#define mil map<int,ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define umli unordered_map<ll,int>
#define umil unordered_map<int,ll>
#define L cout<<'\n';
#define E cerr<<'\n';
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for (int i=a; i<b; ++i)
#define rev(i,a,b) for (int i=a; i>b; --i)
#define revc(i,a,b,c) for (int i=a; i>b; i-=c)
#define repc(i,a,b,c) for (int i=a; i<b; i+=c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setpr(x) cout<<setprecision(x)<<fixed
#define sz size()
#define seea(a,x,y) for(int i=x;i<y;i++){cin>>a[i];}
#define seev(v,n) for(int i=0;i<n;i++){int x; cin>>x; v.push_back(x);}
#define sees(s,n) for(int i=0;i<n;i++){int x; cin>>x; s.insert(x);}
const ll inf = INT_MAX;
const ld ep = 0.0000001;
const ld pi = acos(-1.0);
const int M = 1e9 + 7;
const ll N = 2e5+1;
const int N1 = 101;
const ll modi = 998244353;
vi child[N];
vi primes;
int spf[N];
int mp[N];
int pvisited[N];
int visited[N];
int parent[N];
int logt[1010];
void solve();
void calSPF();
ll ncr(ll n,ll r);
ll NCR[N][N1];
ll calPow(ll a, ll p);
void dfs(int r,int t);
int main(){
    int t = 1;
    see(t);
    while(t--) solve();
}
 
void solve(){
    ll l,r,m;
    see(l,r,m);
    ll dif = r - l;
    rep(i,l,r+1){
        if(m>=i&&m%i <= dif){
            putl(i,l+ (m%i),l);
            return;
        }else if((i - m%i)<=dif){
            putl(i,l,l + (i - m%i));
            return;
        }
    }
}
 


Comments

Submit
0 Comments
More Questions

436. Find Right Interval
435. Non-overlapping Intervals
406. Queue Reconstruction by Height
380. Insert Delete GetRandom O(1)
332. Reconstruct Itinerary
368. Largest Divisible Subset
377. Combination Sum IV
322. Coin Change
307. Range Sum Query - Mutable
287. Find the Duplicate Number
279. Perfect Squares
275. H-Index II
274. H-Index
260. Single Number III
240. Search a 2D Matrix II
238. Product of Array Except Self
229. Majority Element II
222. Count Complete Tree Nodes
215. Kth Largest Element in an Array
198. House Robber
153. Find Minimum in Rotated Sorted Array
150. Evaluate Reverse Polish Notation
144. Binary Tree Preorder Traversal
137. Single Number II
130. Surrounded Regions
129. Sum Root to Leaf Numbers
120. Triangle
102. Binary Tree Level Order Traversal
96. Unique Binary Search Trees
75. Sort Colors