long long mex(long long a, long long b, long long c) { long long d; if (b==0) return 1; if (b==1) return a%c; d=mex(a,b/2,c); d*=d; d%=c; d*=(b&1)?a%c:1; d%=c; return d; }
void SoapServerInternal::Start() { if (m_running) { assert(false); return; } Poco::Net::ServerSocket mex(m_mexPort); Poco::Net::ServerSocket svs(m_rpcPort); //Configure some server params. Poco::Net::TCPServerParams* pTcpParams = new Poco::Net::TCPServerParams(); pTcpParams->setMaxThreads(16); pTcpParams->setMaxQueued(1); Poco::Net::HTTPServerParams* pHttpParams = new Poco::Net::HTTPServerParams; pHttpParams->setMaxThreads(4); //Create your server m_soapTcpServer = shared_ptr<Poco::Net::TCPServer>(new Poco::Net::TCPServer(new TCPServerConnectionFactorySoap(this), svs, pTcpParams)); m_mexHttpServer = shared_ptr<Poco::Net::HTTPServer>(new Poco::Net::HTTPServer(new MexHTTPRequestHandlerFactory(m_wsdlPath), mex, pHttpParams)); m_soapTcpServer->start(); m_mexHttpServer->start(); m_running = true; }
// Enqueue this icholder for release during the next safepoint. It's // not safe to free them until them since they might be visible to // another thread. void InlineCacheBuffer::queue_for_release(CompiledICHolder* icholder) { MutexLockerEx mex(InlineCacheBuffer_lock); icholder->set_next(_pending_released); _pending_released = icholder; _pending_count++; if (TraceICBuffer) { tty->print_cr("enqueueing icholder " INTPTR_FORMAT " to be freed", icholder); } }
int main() { long long x,y,z,w; while(scanf("%I64d %I64d %I64d",&x,&z,&w)==3) { for(y=0;y<=z;y++) if(mex(x,y,z)==w) { printf("%I64d %I64d %I64d\n",x,y,z); break; } } return 0; }
int mex(int p) { //`mex 为求 sg 的函数` int i,t; bool g[101]= {0}; //`定义布尔数组,初值为 0` for(i=0; i<k; i++) { t=p-a[i]; //`t 为 p 当前遍历的后继` if(t<0) break; //`后继最小是 0` if(f[t]==-1)f[t]=mex(t); g[f[t]]=1; //`布尔数组中赋这个 SG 值为` } for(i=0;; i++) { if(!g[i]) return i; } }
int main () { double o,ee,input;int c; for(;;){ printf("-----------------------------------------\n1. Input positive number\n2. Caculate sine x\n3. Caculate square root\n4. Caculate e*x\n5. Quit\n\tYour Answer :");scanf("%d",&c);printf("-----------------------------------------\n"); switch(c){ case 1: printf("-----------------------------------------\nInput positive number :");scanf("%lf",&o); printf("Input error in approximation :");scanf("%lf",&ee);printf("-----------------------------------------\n");break; case 3: printf("-----------------------------------------\n"); if (o < 0) {printf("-----------------------------------------\nCan't Caculate suqare root of negative number !\n-----------------------------------------\n");break;} printf("square root of %.5f = %.5f\n",o,msqrt(o,ee));printf("-----------------------------------------\n");break; case 2: input = o; if( input >= 2*PI) while( input >= 2*PI) input = input - 2*PI; printf("sin(%.5lf) = %.5lf\n",o,msin(input,ee));printf("-----------------------------------------\n");break; case 4: printf("e^%.5lf = %.5f\n",o,mex(o,ee));printf("-----------------------------------------\n");break; case 5:return 0; }}}
int main() { memset(sg, -1, sizeof(sg)); for(int i = 0; i < (1 << 10); i++) sg[0][i] = 0; for(int i = 1; i <= 10; i++) { sg[i][0] = 0; for(int j = 1; j < (1 << 10); j++) { memset(vis, false, sizeof(vis)); for(int k = 0; k < i; k++) if((j >> k) & 1) vis[sg[i - k - 1][j ^ (1 << k)]] = true; sg[i][j] = mex(); } } for(int i = 0; i <= 10; i++) printf("i = %d: sg = %d\n", i, sg[i][(1 << i) - 1]); return 0; }
void CQMergingData::fillTree(QTreeWidget* pW, const CModel* pModel, std::map< QTreeWidgetItem *, const CCopasiObject * > & itemMap, bool flagGlobalQuantities, bool flagReactions, const std::set< const CCopasiObject * > & added, bool highlightInvolved) { itemMap.clear(); pW->clear(); CModelExpansion mex(const_cast<CModel*>(pModel)); //create an italic font for highlighting new model elements QFont tmpFont = pW->font(); tmpFont.setItalic(true); //add the compartments size_t i, imax = pModel->getCompartments().size(); for (i = 0; i < imax; ++i) { const CCopasiObject * pObj = &pModel->getCompartments()[i]; QTreeWidgetItem * pItem = new QTreeWidgetItem((QTreeWidget*)NULL, 1000); pItem->setText(0, FROM_UTF8(pObj->getObjectName())); //highlight new objects std::set<const CCopasiObject * >::const_iterator it = added.find(pObj); if (it != added.end()) { pItem->setFont(0, tmpFont); //pItem->setBackgroundColor(0, QColor(200,200,250)); } //highlight objects that are referred to by others if (highlightInvolved) { if (!mex.existDependentEntities(pObj)) pItem->setTextColor(0, QColor(130, 130, 130)); } itemMap[pItem] = pObj; pW->addTopLevelItem(pItem); pW->setFirstItemColumnSpanned(pItem, true); //add species //QTreeWidgetItem * pChild; size_t j, jmax = pModel->getCompartments()[i].getMetabolites().size(); for (j = 0; j < jmax; ++j) { pObj = &pModel->getCompartments()[i].getMetabolites()[j]; QTreeWidgetItem * pChild = new QTreeWidgetItem(pItem, 1001); pChild->setText(0, FROM_UTF8(pObj->getObjectName())); pW->setFirstItemColumnSpanned(pChild, true); //highlight new objects std::set< const CCopasiObject * >::const_iterator it = added.find(pObj); if (it != added.end()) { pChild->setFont(0, tmpFont); //pChild->setBackgroundColor(0, QColor(200,200,250)); } //highlight objects that are referred to by others if (highlightInvolved) { if (!mex.existDependentEntities(pObj)) pChild->setTextColor(0, QColor(130, 130, 130)); } itemMap[pChild] = pObj; } pItem->setExpanded(true); } if (flagGlobalQuantities && pModel->getModelValues().size()) { QTreeWidgetItem * pItem = new QTreeWidgetItem((QTreeWidget*)NULL, 1000); pItem->setText(0, "Global Quantities"); pW->addTopLevelItem(pItem); pW->setFirstItemColumnSpanned(pItem, true); //QTreeWidgetItem * pChild; size_t j, jmax = pModel->getModelValues().size(); for (j = 0; j < jmax; ++j) { const CCopasiObject * pObj = &pModel->getModelValues()[j]; QTreeWidgetItem * pChild = new QTreeWidgetItem(pItem, 1001); pChild->setText(0, FROM_UTF8(pObj->getObjectName())); pW->setFirstItemColumnSpanned(pChild, true); //highlight new objects std::set< const CCopasiObject * >::const_iterator it = added.find(pObj); if (it != added.end()) { pChild->setFont(0, tmpFont); //pChild->setBackgroundColor(0, QColor(200,200,250)); } //highlight objects that are referred to by others if (highlightInvolved) { if (!mex.existDependentEntities(pObj)) pChild->setTextColor(0, QColor(130, 130, 130)); } itemMap[pChild] = pObj; } } if (flagReactions && pModel->getReactions().size()) { pW->setColumnCount(2); QTreeWidgetItem * pItem = new QTreeWidgetItem((QTreeWidget*)NULL, 1000); pItem->setText(0, "Reactions"); pW->addTopLevelItem(pItem); pW->setFirstItemColumnSpanned(pItem, true); QFont tmpFontSmall = pItem->font(0); tmpFontSmall.setPointSize(tmpFontSmall.pointSize() - 2); //QTreeWidgetItem * pChild; size_t j, jmax = pModel->getReactions().size(); for (j = 0; j < jmax; ++j) { const CCopasiObject * pObj = &pModel->getReactions()[j]; QTreeWidgetItem * pChild = new QTreeWidgetItem(pItem, 1001); pChild->setText(0, FROM_UTF8(pObj->getObjectName())); pW->setFirstItemColumnSpanned(pChild, false); //add the chemical equation (with a smaller font) const CReaction * pReaction = dynamic_cast<const CReaction*>(pObj); if (pReaction) pChild->setText(1, FROM_UTF8(CChemEqInterface::getChemEqString(const_cast<CModel*>(pModel), *pReaction, false))); pChild->setFont(1, tmpFontSmall); //highlight new objects std::set< const CCopasiObject * >::const_iterator it = added.find(pObj); if (it != added.end()) { pChild->setFont(0, tmpFont); //pChild->setBackgroundColor(0, QColor(200,200,250)); } //highlight objects that are referred to by others if (highlightInvolved) { if (!mex.existDependentEntities(pObj)) pChild->setTextColor(0, QColor(130, 130, 130)); pChild->setTextColor(1, QColor(130, 130, 130)); } itemMap[pChild] = pObj; } //pW->setCo } }