Topcoder SRM 535(Div.2) Report

"Fox Jiro and Eel Saburo are good friends."

250-problem:It is the problem of the simultaneous equations. These equations are symmetric, so I can get answer by addition and subtraction of two equations. This have no answer because there are four expressions for three unknown quantity.  I am after a long absence, I solve this problem very carefully.208.97pts.

500-problem: Use Euclid's Algorithm and next theorem: m*n=GCD(m,n)*LCM(m,n). I found all L's divisor. I think, I could get L's divisor which is multiple of G. If we get the list, this problems was easier.284.88pts.

Problems are here.
Score=493.85, Standings=81/1412. Rating 1125->1200. I became Blue Coder(Division 1), I'm worry about next contest.



using namespace std;

class FoxAndIntegers{
vector <int> get(int AminusB, int BminusC, int AplusB, int BplusC){
vector<int> ret(3);
vector<int> empty(0);
if((AplusB + AminusB)%2!=0) return empty;
if((BplusC - BminusC)%2!=0) return empty;
if((AplusB - AminusB)%2!=0) return empty;
if((AplusB - AminusB)!=(BplusC + BminusC)) return empty; 
ret[0]=(AplusB + AminusB)/2;
ret[1]=(AplusB - AminusB)/2;
ret[2]=(BplusC - BminusC)/2;
return ret;



using namespace std;

class FoxAndGCDLCM{
long long get(long long G, long long L){
long long sum=-1,tmp;
for(long long i=1;i*i<=L;i++){
if(L%i!=0) continue;
if(euclid(i,tmp-i)==G && (sum>tmp || sum==-1)) sum=tmp;
long long k=L/i;
if(euclid(k,tmp-k)==G && (sum>tmp || sum==-1) ) sum=tmp;
return sum;

long long euclid(long long a,long long b){
if(b==0) return a;
return euclid(b,a%b);

0 件のコメント: