Skip to content

Instantly share code, notes, and snippets.

@ynh
Created September 4, 2012 15:59
Show Gist options
  • Save ynh/3622746 to your computer and use it in GitHub Desktop.
Save ynh/3622746 to your computer and use it in GitHub Desktop.
ACPC10E
//============================================================================
// 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