Created
September 4, 2012 15:59
-
-
Save ynh-zz/3622748 to your computer and use it in GitHub Desktop.
ACPC10E
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//============================================================================ | |
// Name : SPOJ.cpp | |
// Author : | |
// Version : | |
// Copyright : Your copyright notice | |
// Description : Hello World in C++, Ansi-style | |
//============================================================================ | |
#include <iostream> | |
#include <stdio.h> | |
#include <math.h> | |
using namespace std; | |
int main() { | |
long G=1,T=0,A=0,D=0; | |
while(G!=-1||T!=-1||A!=-1||D!=-1){ | |
scanf ("%ld %ld %ld %ld\n",&G,&T,&A,&D); | |
if(G>0){ | |
long teams=G*A+D; | |
long p2=ceil(log2(teams)); | |
long h2=pow(2,p2); | |
long Y=h2-teams; | |
long X=h2-1+G*(T-1)*T/2; | |
printf ("%ld*%ld/%ld+%ld=%ld+%ld\n",G,A,T,D,X,Y); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment