void servercontroller::saveSessionConfig() { QDictIterator<KSircProcess> ksp(proc_list); for (; ksp.current(); ++ksp ) { ChannelSessionInfoList channels; QDictIterator<KSircMessageReceiver> ksm(ksp.current()->getWindowList()); for (; ksm.current(); ++ksm ) if(ksm.currentKey()[0] != '!') { // Ignore !ksm's (system created) ChannelSessionInfo sessionInfo; sessionInfo.name = ksm.currentKey(); sessionInfo.port = ksp.current()->serverPort(); KSircTopLevel *topLev = dynamic_cast<KSircTopLevel *>( ksm.current() ); if ( topLev && topLev->isTopLevel() ) { #ifdef Q_WS_X11 NETWinInfo winInfo( qt_xdisplay(), topLev->winId(), qt_xrootwin(), NET::WMDesktop ); sessionInfo.desktop = winInfo.desktop(); #endif } channels << sessionInfo; } if ( !channels.isEmpty() ) m_sessionConfig[ ksp.currentKey() ] = channels; } }
int main() { int T,a,n,p,i,ans; shai(); scanf("%d",&T); while (T--) { scanf("%d%d",&a,&n); p=phi[n]; ans=0; for (i=1;i<=(int)sqrt(p);i++) if (p%i==0) { if (ksm(a,i,n)==1) ans=max(ans,i); if (ksm(a,p/i,n)==1) ans=max(ans,p/i); } printf("%d\n",ans); } return 0; }
int main( int argc, char* argv[] ) { // ARGUMENT PARSING // osg::ArgumentParser args( &argc, argv ); args.getApplicationUsage()->setApplicationName( args.getApplicationName() ); args.getApplicationUsage()->setDescription(args.getApplicationName()+" demonstrates osgVRPN"); args.getApplicationUsage()->setCommandLineUsage(args.getApplicationName()+" [options]"); args.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); args.getApplicationUsage()->addKeyboardMouseBinding( "1", "Trackball manipulator" ); args.getApplicationUsage()->addKeyboardMouseBinding( "2", "Tracker manipulator" ); // INITIALIZE TRACKER // osgVRPN::Analog* analog( new osgVRPN::Analog( "Wanda@localhost" ) ); osgVRPN::Button* button( new osgVRPN::Button( "Wanda@localhost" ) ); osgVRPN::VRTracker* tracker( new osgVRPN::VRTracker( "Tracker0@localhost", 1 ) ); // ID for Flock HMD osgVRPN::VRManipulator* manip( new osgVRPN::VRManipulator( tracker ) ); manip->setAutoComputeHomePosition( false ); osgVRPN::DeviceBundle::Instance()->addAnalog( analog ); osgVRPN::DeviceBundle::Instance()->addButton( button ); osgVRPN::DeviceBundle::Instance()->addTracker( tracker ); osgVRPN::DeviceBundle::Instance()->addManipulator( manip ); osgVRPN::DevicesCallback* devices( new osgVRPN::DevicesCallback( osgVRPN::DeviceBundle::Instance() ) ); // INITIALIZE CAMERA // osgViewer::Viewer viewer; viewer.getUsage( *args.getApplicationUsage() ); if (args.read("-h") || args.read("--help")) { args.getApplicationUsage()->write( std::cout ); return 1; } osg::StateSet* ss( viewer.getCamera()->getOrCreateStateSet() ); viewer.addEventHandler( new osgGA::StateSetManipulator( ss ) ); viewer.addEventHandler( new osgViewer::HelpHandler( args.getApplicationUsage() ) ); viewer.addEventHandler( new osgViewer::ThreadingHandler ); viewer.addEventHandler( new osgViewer::WindowSizeHandler ); viewer.addEventHandler( new osgViewer::StatsHandler ); viewer.addEventHandler( new osgViewer::LODScaleHandler ); viewer.addEventHandler( new osgViewer::ScreenCaptureHandler ); viewer.addEventHandler( new osgVRPN::WalledModeHandler( manip ) ); osgGA::KeySwitchMatrixManipulator* ksm( new osgGA::KeySwitchMatrixManipulator ); viewer.setCameraManipulator( ksm ); // CREATE SCENE // osg::Group* scene( new osg::Group ); osg::Node* world( new osg::Node ); if( args.argc() > 1 ) { world = osgDB::readNodeFiles(args); } else { world = osgDB::readNodeFile( "Images/stadium.ive.[-90,180,0].rot.[-1500,-250,4200].trans" ); } scene->addChild( world ); scene->addUpdateCallback( devices ); // SET HOME MATRIX AND ADD MANIPULATORS // ksm->addMatrixManipulator( '1', "Tracker", manip ); ksm->addMatrixManipulator( '2', "Trackball", new osgGA::TrackballManipulator() ); // Increase the field of view so we can see a good portion of the stadium. double fovy, aspectRatio, zNear, zFar; osg::ref_ptr<osg::Camera> camera = viewer.getCamera(); camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR ); camera->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); fovy *= 2.5; /*aspectRatio *= 2;*/ zNear *= 5; zFar *= 5; camera->setProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); // Set the model. Lighting is terrible, but osg::View::NO_LIGHT // seems to work. osgUtil::Optimizer optimizer; optimizer.optimize( scene ); viewer.setSceneData( scene ); viewer.setLightingMode( osg::View::NO_LIGHT ); // VRManipulator navigation functions have Y up. viewer.frame(); osg::Vec3 eye( 0, 0, -1 ); osg::Vec3 center( 0, 0, 0 ); osg::Vec3 up( 0, 1, 0 ); osg::Matrix matrix; matrix.makeLookAt( eye, center, up ); manip->setHomeMatrix( matrix ); // MAIN LOOP // unsigned int numAnalogs = 0; float analogVal = 0.0f; while(!viewer.done()) { if ( numAnalogs >= 1 ) { // Allow for a certain tolerance in moving the joystick. analogVal = osgVRPN::DeviceBundle::Instance()->getValue( 0, 0 ); if ( analogVal > 0.2f || analogVal < -0.2f ) { manip->navRotate( osg::DegreesToRadians( -analogVal ), osg::Vec3( 0, 1, 0 ) ); } } numAnalogs = osgVRPN::DeviceBundle::Instance()->getNumChannels( 0 ); viewer.frame(); } return 0; }