int main() { int x = 1; int y = 1; // printf("pentagonal(20000) = %llu\n", pentagonal(20000)); // return 0; for(x=1; ; ++x) { for(y=1; y<=x; ++y) { if(meetsCriteria(pentagonal(x), pentagonal(y))) { printf("pentagonal(x)=%lld, pentagonal(y)=%lld, diff(x,y)=%lld\n", pentagonal(x), pentagonal(y), diff(pentagonal(x), pentagonal(y))); return 0; } // if(x % 100 == 0 || y % 100 == 0) // { // printf("(x,y) : (%d,%d)\n", x, y); // } } } return 0; }
long TeamSensorSystem::getContacts (GameObjectPtr looker, long* contactList, long contactCriteria, long sortType) { if ((sortType != CONTACT_SORT_NONE) && !looker) return(0); static float sortValues[MAX_CONTACTS_PER_SENSOR]; float CV = 0; long numValidContacts = 0; long handleList[MAX_CONTACTS_PER_SENSOR]; for (long i = 0; i < numContacts; i++) { MoverPtr mover = (MoverPtr)ObjectManager->get(contacts[i]); if (!meetsCriteria(looker, mover, contactCriteria)) continue; handleList[numValidContacts] = mover->getHandle(); switch (sortType) { case CONTACT_SORT_NONE: sortValues[numValidContacts] = 0.0; break; case CONTACT_SORT_CV: CV = (float)mover->getCurCV(); sortValues[numValidContacts] = CV; break; case CONTACT_SORT_DISTANCE: sortValues[numValidContacts] = looker->distanceFrom(mover->getPosition()); break; } numValidContacts++; } if ((numValidContacts > 0) && (sortType != CONTACT_SORT_NONE)) { //--------------------------------------------------------- // BIG ASSUMPTION HERE: That a mech will not have more than // MAX_CONTACTS_PER_SENSOR contacts. if (!SensorSystem::sortList) { SensorSystem::sortList = new SortList; if (!SensorSystem::sortList) Fatal(0, " Unable to create Contact sortList "); SensorSystem::sortList->init(MAX_CONTACTS_PER_SENSOR); } bool descendSort = true; if (sortType == CONTACT_SORT_DISTANCE) descendSort = false; SensorSystem::sortList->clear(descendSort); for (long contact = 0; contact < numValidContacts; contact++) { SensorSystem::sortList->setId(contact, handleList[contact]); SensorSystem::sortList->setValue(contact, sortValues[contact]); } SensorSystem::sortList->sort(descendSort); for (contact = 0; contact < numValidContacts; contact++) contactList[contact] = SensorSystem::sortList->getId(contact); } else if (contactList) for (long contact = 0; contact < numValidContacts; contact++) contactList[contact] = handleList[contact]; return(numValidContacts); }