Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by AMIR ( 14 years ago )
//In Love Turtles
//Author: A & Sh
//Date: 1391/1/16
//Headers
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;
//Init Data
typedef pair<int,int> coordinate;
coordinate co[3];
coordinate co_new[3];
int ar[2][9] = {{-1,-1,-1,0,0,0,1,1,1},{-1,0,1,-1,0,1,-1,0,1}};
//Constants
const int DELTA = 97987;
//Proto-Types
bool setNew(int i);
void goNew(int i);
//Main Program
int main()
{
co[0] = coordinate(1024,2010);
co[1] = coordinate(-1381,138);
co[2] = coordinate(1,2010);
int sec = 0;
bool s1,s2,s3;
s1 = setNew(0);
s2 = setNew(1);
s3 = setNew(2);
while (s1 || s2 || s3)
{
if (s1)
goNew(0);
if (s2)
goNew(1);
if (s3)
goNew(2);
sec++;
s1 = setNew(0);
s2 = setNew(1);
s3 = setNew(2);
}
cout << sec << endl;
int res = 1;
for (int i = 0; i < 6; i++)
{
res *= sec % DELTA;
res %= DELTA;
}
cout << res << endl;
return 0;
}
//Function Implementations
void goNew(int i)
{
co[i] = co_new[i];
}
bool setNew(int i)
{
int dest = (i+1) % 3;
int Min = INT_MAX;
coordinate Addr;
coordinate Temp;
for (int j = 0; j < 9; j++)
{
Temp = coordinate(co[i].first+ar[0][j], co[i].second+ar[1][j]);
if (Temp == co[dest])
return false;
if (abs(Temp.first - co[dest].first) + abs(Temp.second - co[dest].second) < Min)
{
Min = abs(Temp.first - co[dest].first) + abs(Temp.second - co[dest].second);
Addr = Temp;
}
}
co_new[i] = Addr;
return true;
}
Revise this Paste