Question:
Here is l, R ~ Whether there is a mutual quality between R and B, B and C, but A and C are not mutually qualitative; where l <= A <B <C <= r; If yes, output A, B, and C. Output-1 if the input parameter does not exist;
Among them, (1 segment ≤ segmentLLimit ≤ limitRLimit ≤ limit 1018;RAccept-Encoding-LLimit ≤ limit 50 ).
--R-l <= 50, so I am also drunk, open a Longlong, enumerative whether they meet the above requirements, by the way, I reviewed it;
#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>using namespace std;long long l,r;int gcd(long long a,long long b){if(b==0) return a;else return gcd(b,a%b);}int main(){cin>>l>>r;for(long long i=l;i<=r;i++) for(long long j=i+1;j<=r;j++) for(long long k=j+1;k<=r;k++){ if(i!=j && i!=k && j!=k){ if(gcd(j,i)==1 && gcd(k,j)==1 && gcd(k,i)!=1){ cout<<i<<" "<<j<<" "<<k; return 0; } } }cout<<"-1";return 0;}
Question B:
You give the number of cnt1 to the first friend and the number of cnt2 to the second friend. The number of cnt2 to the first friend cannot be divisible by X, and the number to the second friend cannot be divisible by Y, if a number cannot be divisible by X or Y, it cannot appear in the number of two friends at the same time.
Then you have to select the number of Cn1 and cnt2 that meet the requirements in 1.2.3... n, and ask you the minimum number of N?
I feel that this set of questions B is very difficult--(in fact, I am weak ....)
At the beginning, I thought it would be okay to enumerate. Question B is correct, and then it still times out. Then I thought it would be better to optimize the brute force.-The result is still not good;
Later think of the use of remainder, such as X number, there can be a number of X-1 not divisible by X, but the answer to the processing will still be biased
Then there is no way! I read other people's code! -Mom, you have all the ideas about using the remainder, but you still don't know what to do! I'm stupid ....
The above is my silly thinking process.--The correct idea of this question is the conventional binary answer;
What if the verification is feasible? (There are many methods. Here I will talk about my ideas)
If that number
Codeforces #275 div2