int main()
{
 long n;
 scanf("%ld",&n);
 if(n==0)
                printf("zero");
 else
 {
                  pw(((n/1000)%100),"thousand");
                  pw(((n/100)%10),"hundred");
                  pw((n%100)," ");
 }
 getch();
 return 0;
}
void mepp_component_CGAL_Example_plugin::step5()
{
	QApplication::setOverrideCursor(Qt::WaitCursor);

	// active viewer
	if (mw->activeMdiChild() != 0)
	{
		Viewer* viewer = (Viewer *)mw->activeMdiChild();
		PolyhedronPtr polyhedron_ptr = viewer->getScenePtr()->get_polyhedron();

		CGAL_Example_ComponentPtr component_ptr = findOrCreateComponentForViewer<CGAL_Example_ComponentPtr, CGAL_Example_Component>(viewer, polyhedron_ptr);
		
		Vec pw(2, 0, 0); viewer->frame(viewer->getScenePtr()->get_current_polyhedron())->setPosition(pw); // position in world coordinate system
		//Vec pl(2, 0, 0); viewer->frame(viewer->getScenePtr()->get_current_polyhedron())->setTranslation(pl); // local frame translation

		Quaternion qw(0, 0, 0, 1); // identity quaternion (i.e., no rotation)
		viewer->frame(viewer->getScenePtr()->get_current_polyhedron())->setOrientation(qw); // rotation in world coordinate system
		/*Quaternion ql(0, 0, 0, 1); // identity quaternion (i.e., no rotation)
		viewer->frame(viewer->getScenePtr()->get_current_polyhedron())->setRotation(ql); // local frame rotation*/

		viewer->updateGL();
	}

	QApplication::restoreOverrideCursor();
}
示例#3
0
void debruijn( int n, int k ){
    seq = "";
    char s[n];
    if ( n == 1 ){
        for ( int i = 0; i < k; i++ )
            seq += char('0'+i);
    }
    else{
        for ( int i = 0; i < n-1; i++ )
            s[i] = k-1;
        
        int kn = pw(k, n-1);
        char nxt[kn]; memset(nxt, 0, sizeof(nxt));
        kn *= k;
        for ( int h = 0; h < kn; h++ ){
            int m = 0;
            for ( int i = 0; i < n-1; i++ ){
                m *= k;
                m += s[(h+i)%(n-1)];
            }
            seq += char('0'+nxt[m]);
            s[h%(n-1)] = nxt[m];
            nxt[m]++;
        }
    }
}
示例#4
0
static void panel_sleep(int enable)
{
	printk("panel_sleep(%i)\n", enable);
	
	if (enable) {
		pw( 0x10 );
		msleep(500);
		pw( 0x28 );
		msleep(500);
	} else {
		pw( 0x11 );
		msleep(500);
		pw( 0x29 );
		msleep(500);
	}
}
示例#5
0
文件: binheap.c 项目: KHN190/cisb212
        void 
        PrintHeap( PriorityQueue H )
        {
            // basic information
            printf( KCYN "\n\tChild:\t%d\n", H->Child);
            printf("\tHeight:\t%d\n", Height( H )); 
            printf("\tSize:\t%d\n\n" RESET, H->Size);

        	int i, j;
            int first, last;

            first = 1;

        	for ( j = 0; j <= Height( H ); ++j )
        	{
        		// find last element
                last = first + pw( H->Child, j );

        		// print a level
                printf(KGRN "%d: " RESET, j);
        		for ( i = first; i < last && i <= H->Size; ++i )
	        		printf("%d ", H->Elements[ i ]);
				puts("");
                // find first element
                first = last;
        	}
        }
示例#6
0
void ImageItem::paintEvent(QPaintEvent * e)
{
	QPainter pw(this);


	// Actual fading
	QPixmap transparent(mPixmap.size());
	transparent.fill(QColor(200,200,200,128));
	QPainter p(&transparent);
	p.setCompositionMode(QPainter::CompositionMode_SourceOver);
	p.drawPixmap(0,0, mPixmap);
	if(!mInfoText.isEmpty())
	{
		p.setPen( Qt::black );
		p.drawText(4,4,transparent.rect().width(),transparent.rect().height(),
				   Qt::AlignTop | Qt::TextWordWrap,
				   mInfoText);
	}
	p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
	p.fillRect(transparent.rect(), QColor(0, 0, 0, mFade));

	p.end();

	pw.drawPixmap(0,0, transparent);



}
示例#7
0
void  RichTextView::Paint(Draw& w)
{
	Size sz = GetSize();
	w.DrawRect(sz, background);
	sz.cx -= margin.left + margin.right;
	sz.cy -= margin.top + margin.bottom;
	w.Clipoff(margin.left, margin.top, sz.cx, sz.cy);
	PaintInfo pi;
	if(!hldec)
		pi.hyperlink = Null;
	if(sell < selh) {
		pi.sell = sell;
		pi.selh = selh;
	}
	pi.indexentry = Null;
	pi.highlightpara = highlight;
	pi.zoom = GetZoom();
	int q = sb * pi.zoom;
	scroller.Set(q);
	w.Offset(0, -q);
	SimplePageDraw pw(w);
	pi.top = PageY(0, sb);
	pi.bottom = PageY(0, sb + sz.cy / pi.zoom);
	pi.usecache = true;
	pi.sizetracking = sizetracking;
	pi.shrink_oversized_objects = shrink_oversized_objects;
	Color c = SColorPaper();
	if(Grayscale(c) < 100)
		pi.coloroverride = true;
	text.Paint(pw, GetPage(), pi);
	w.End();
	w.End();
}
示例#8
0
void Print(Draw& w, const RichText& text, const Rect& page, const Vector<int>& pg)
{
	LLOG("Print");
	int lpage = text.GetHeight(page).page;
	PrintPageDraw pw(w);
	Size sz = w.GetPageMMs();
	Size pgsz = page.Size();
	int x = (6000 * sz.cx / 254 - pgsz.cx) / 2;
	int y = (6000 * sz.cy / 254 - pgsz.cy) / 2;
	for(int pi = 0; pi < pg.GetCount(); pi++) {
		int i = pg[pi];
		w.StartPage();
		w.Offset(x, y);
		pw.SetPage(i);
		PaintInfo paintinfo;
		paintinfo.top = PageY(i, 0);
		paintinfo.bottom = PageY(i + 1, 0);
		paintinfo.indexentry = Null;
		if(text.IsPrintNoLinks())
			paintinfo.hyperlink = Null;
		text.Paint(pw, page, paintinfo);
		w.End();
		String footer = text.GetFooter();
		if(!IsNull(footer) && lpage) {
			String n = Format(footer, i + 1, lpage + 1);
			Size nsz = GetTextSize(n, Arial(90).Italic());
			pw.Page(i).DrawText(
				x + pgsz.cx - nsz.cx, y + pgsz.cy + 100,
				n, Arial(90).Italic());
		}
		w.EndPage();
	}
}
示例#9
0
ll pw(ll a, ll b){
  ll r;
  if(b==0) return 1;
  r = pw(a,b/2);
  r = (r*r)%M;
  if(b%2) r = (r*a)%M;
  return r;
}
ll pw(ll a, ll b,ll p){
  ll r;
  if(b==0) return 1;
  r = pw(a,b/2,p);
  r = (r*r)%p;
  if(b%2) r = (r*a)%p;
  return r;
}
示例#11
0
int main() {
  long long n;
  scanf("%lld", &n);

  // 3^n
  long long a = 3, mod = 2147483647;
  long long r = pw(3, n, mod);
  printf("%lld\n", r);
}
示例#12
0
int main()
{
    ll t, n, k ;
    scanf("%lld", &t);
    while(t--){
        scanf("%lld %lld", &n , &k) ;
        printf("%lld\n", (pw(k-1, n-1)*k)%M);
    }
return 0 ;
}
示例#13
0
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void PrintBrush( bspbrush_t *brush ) {
	int i;

	printf( "brush: %p\n", brush );
	for ( i = 0; i < brush->numsides ; i++ )
	{
		pw( brush->sides[i].winding );
		printf( "\n" );
	} //end for
} //end of the function PrintBrush
示例#14
0
/** set X, Y, W, and H to the bounding box of point /p/ in screen coords */
void
Panner::point_bbox ( const Point *p, int *X, int *Y, int *W, int *H ) const
{
    int tx, ty, tw, th;

    bbox( tx, ty, tw, th );

    tw -= pw();
    th -= ph();

    float px, py;

    p->axes( &px, &py );

    *X = tx + ((tw / 2) * px + (tw / 2));
    *Y = ty + ((th / 2) * py + (th / 2));

    *W = pw();
    *H = ph();
}
示例#15
0
void PrintBrush (bspbrush_t *brush)
{
	int		i;

	Msg("brush: %p\n", brush);
	for (i=0;i<brush->numsides ; i++)
	{
		pw(brush->sides[i].winding);
		Msg("\n");
	}
}
示例#16
0
文件: write_test.cpp 项目: o11c/tmwa
TEST(io, write1)
{
    PipeWriter pw(false);
    io::WriteFile& wf = pw.wf;
    wf.really_put("Hello, ", 7);
    EXPECT_EQ(""_s, pw.slurp());
    wf.put_line("World!\n"_s);
    EXPECT_EQ(""_s, pw.slurp());
    EXPECT_TRUE(wf.close());
    EXPECT_EQ("Hello, World!\n"_s, pw.slurp());
}
示例#17
0
bool CPermissionsCache::lookup(ISecUser& sec_user)
{
    if(!isCacheEnabled())
        return false;

    const char* username = sec_user.getName();
    if(!username || !*username)
        return false;

    string key(username);
    ReadLockBlock readLock(m_userCacheRWLock );

    MapUserCache::iterator it = m_userCache.find(key);
    if (it == m_userCache.end())
        return false;
    CachedUser* user = (CachedUser*)(it->second);

    time_t now;
    time(&now);
    if(user->getTimestamp() < (now - m_cacheTimeout))
    {
        m_userCache.erase(username);
        delete user;
        return false;
    }

    const char* cachedpw = user->queryUser()->credentials().getPassword();
    StringBuffer pw(sec_user.credentials().getPassword());
    
    if(cachedpw && pw.length() > 0)
    {
        StringBuffer md5pbuf;
        md5_string(pw, md5pbuf);
        if(strcmp(cachedpw, md5pbuf.str()) == 0)
        {
#ifdef _DEBUG
            DBGLOG("CACHE: CPermissionsCache Found validated user %s", username);
#endif
            // Copy cached user to the sec_user structure, but still keep the original clear text password.
            user->queryUser()->copyTo(sec_user);
            sec_user.credentials().setPassword(pw.str());
            return true;
        }
        else
        {
            m_userCache.erase(username);
            delete user;
            return false;
        }
    }

    return false;
}
示例#18
0
int main(int argc, char** argv)
{

  bem2d::freqtype k={10,0};
        int n=3*k.re;




        std::vector<bem2d::Point> triangle;
        triangle.push_back(bem2d::Point(0,0));
        triangle.push_back(bem2d::Point(1,0));
        triangle.push_back(bem2d::Point(.5,.5*sqrt(3)));
        bem2d::Polygon poly(triangle,n);
        bem2d::pGeometry pgeom=poly.GetGeometry();



        bem2d::PolBasis::AddBasis(0,pgeom);


        bem2d::Point direction=bem2d::normalize(bem2d::Point(1,1));
        bem2d::PlaneWave pw(direction,k);
        bem2d::CombinedPlaneWave cpw(direction,k);

        bem2d::SoundSoftScattering<bem2d::PlaneWave,bem2d::CombinedPlaneWave> soundsoft(pgeom,k,pw,cpw);
        soundsoft.SetQuadOption(5,5,0.15);
        soundsoft.set_polygons(pgeom);
        soundsoft.set_plotInterior();



        std::cout << "Discretizing with k=" << bem2d::complex(k.re,k.im) << " and n=" << pgeom->size() << std::endl;
        clock_t start, finish;
        double time;

        start=clock();
        soundsoft.Discretize();
        finish=clock();
        time=(double(finish)-double(start))/CLOCKS_PER_SEC;
        std::cout << "Computing time (minutes): " << time/60 << std::endl;



        int xpts=300;
        int ypts=300;
        bem2d::pOutputHandler pout(new bem2d::GplotOutput(xpts,ypts,-4,8,-4,8,"wedge"));
        soundsoft.SetOutput(pout);
        soundsoft.WriteAll();


}
示例#19
0
文件: binheap.c 项目: KHN190/cisb212
        void 
        _PercolateDown( PriorityQueue H, int i )
        {
            int tmp, cnt, j;
            int Child, MinChild;

            /* Find the level */
            for ( j = 0; pw(H->Child, j+1)-1 <= H->Size; ++j )
            {
                if ( pw(H->Child, j+1)-1 >= i )
                    break;
            }

            Child = _FirstChild( H->Child, i, j+1 );
            MinChild = Child;

            /* Loop through children */
            for ( cnt = 0; cnt < H->Child; ++cnt )
            {
                if ( Child > H->Size )
                    return;

                if ( H->Elements[ Child ] < H->Elements[ MinChild ] )
                    MinChild = Child;

                ++Child;
            }
            Child = MinChild;

            /* Percolate one level */
            if( H->Elements[ i ] > H->Elements[ Child ] )
            {
                tmp = H->Elements[ i ];
                H->Elements[ i ] = H->Elements[ Child ];
                H->Elements[ Child ] = tmp;
            }

            _PercolateDown( H, Child );
        }
示例#20
0
void show_cb(Fl_Widget *,void *) 
{
   Fl_Popup_Window pw(10,10,200,200,"Popup Window");
   pw.box(FL_BORDER_BOX);
   pwp = &pw;
   Fl_Box          bx(5,5,190,50,"Click on the button \nor outside this window");
   bx.align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
   Fl_Button       bt(10,60,180,20,"Click me");
   bt.callback(hide_cb);
   pw.end();
      
   pw.show_popup();
}
示例#21
0
    seventy"," eighty"," ninety"};


void main()
{
    long n;
    clrscr();
    printf("
            Enter any 9 digit no: ");
    scanf("%9ld",&n);
    if(n<=0)
        printf("Enter numbers greater than 0");
    else
    {
        pw((n/10000000),"crore");
        pw(((n/100000)%100),"lakh");
        pw(((n/1000)%100),"thousand");
        pw(((n/100)%10),"hundred");
        pw((n%100)," ");
    }
    getch();
}
示例#22
0
int pw(int number,int pwer)
{
		if(pwer==0)
				return 1;
		else
		{
				int t = pw(number*number,pwer/2);
				if(pwer%2==1)
						return t*number;
				else
						return t;
		}

}
示例#23
0
文件: accumul.c 项目: Giamp/lezioni
int main()
{
    int c1[2]={0,0},c2[10]={0,0,0,0,0,0,0,0,0,0},c3[3]={0,0,0};
    int i;
    
    
    f(10,2,c1); f(2,2,c1); f(pw(2,12),2,c1);        //[2,2] + [1,1] + [12,1]
    printf ("%i %i\n",c1[0],c1[1]);
    
    f(10,10,c2); f(2,10,c2); f(16,10,c2); f(1627,10,c2);    // [1,1,0,0,...] + [0,0,1,..] + [0,1,0,0,0,0,1,...] + [0, 1, 1, 0, 0, 0, 1, 1, 0, ...]
    for (i=0;i<10;i++)
        printf ("%i ",c2[i]);
    printf ("\n");
}
示例#24
0
void RichText::Paint(Draw& w, int x, int y, int cx, const PaintInfo& pinit) const
{
	Mutex::Lock __(mutex);
	SimplePageDraw pw(w);
	PaintInfo pi(pinit);
	pi.top = PageY(0, 0);
	pi.bottom = PageY(0, INT_MAX);
	pi.usecache = true;
	pi.sizetracking = false;
	pi.highlight = Null;
	w.Offset(x, y);
	Paint(pw, Size(cx / pi.zoom, INT_MAX), pi);
	w.End();
}
bool Import_PwManager::xml_parseEntryAttributes(QDomElement* EntryElement,IGroupHandle* NewGroup){
	IEntryHandle* e=database->newEntry(NewGroup);
	e->setTitle(EntryElement->elementsByTagName("d").item(0).toElement().text());
	e->setUsername(EntryElement->elementsByTagName("n").item(0).toElement().text());
	QString pw(EntryElement->elementsByTagName("p").item(0).toElement().text());
	SecString spw;
	spw.setString(pw,true);
	e->setPassword(spw);
	QString comment=EntryElement->elementsByTagName("c").item(0).toElement().text();
	comment.replace("$>--endl--<$","\n");
	e->setComment(comment);
	e->setUrl(EntryElement->elementsByTagName("u").item(0).toElement().text());
	return true;
}
int main()
{
    ll t,product,n,i,p,y;
    scanf("%lld",&t);
    while(t--)
    {
        product=1;
        scanf("%lld %lld",&n,&p);
        if(n>=p/3.0)
        printf("0\n");
        else
        {
        for(i=1;i<=3*n;i++)
        {
            product=(product*i)%p;
        }
        y=pw(6,p-2,p);
        y=pw(y,n,p);
        product*=y;
        printf("%lld\n",product%p);
        }
    }
    return 0;
}
示例#27
0
int main(int argc, char *argv[])
{
    QApplication::setApplicationName("Presi-aoke");
    QApplication::setOrganizationName("Frank Hunleth");
    QApplication::setOrganizationDomain("hunleth.com");
    QApplication::setApplicationVersion("0.1");

    QApplication a(argc, argv);

    Settings settings;
    PresentationWidget pw(&settings);
    pw.show();

    return a.exec();
}
示例#28
0
bool CPermissionsCache::lookup(ISecUser& sec_user)
{
    if(!isCacheEnabled())
        return false;

    const char* username = sec_user.getName();
    if(!username || !*username)
        return false;

    synchronized block(m_userCacheMonitor); 

    CachedUser* user = m_userCache[username];
    if(user == NULL)
        return false;       
    time_t now;
    time(&now);
    if(user->getTimestamp() < (now - m_cacheTimeout))
    {
        m_userCache.erase(username);
        delete user;
        return false;
    }

    const char* cachedpw = user->queryUser()->credentials().getPassword();
    StringBuffer pw(sec_user.credentials().getPassword());
    
    if(cachedpw && pw.length() > 0)
    {
        StringBuffer md5pbuf;
        md5_string(pw, md5pbuf);
        if(strcmp(cachedpw, md5pbuf.str()) == 0)
        {
            // Copy cached user to the sec_user structure, but still keep the original clear text password.
            user->queryUser()->copyTo(sec_user);
            sec_user.credentials().setPassword(pw.str());
            return true;
        }
        else
        {
            m_userCache.erase(username);
            delete user;
            return false;
        }
    }

    return false;
}
示例#29
0
void AccountPage::act()
{
    if( tarsnap )
	delete tarsnap;
    tarsnap = new QProcess( this );
    tarsnap->setProcessChannelMode( QProcess::MergedChannels );
    QStringList cli;
    cli << "--keyfile" << file->text().toUtf8()
	<< "--user" << login->text().toUtf8()
	<< "--machine" << host->text().toUtf8();
    connect( tarsnap, SIGNAL(finished(int, QProcess::ExitStatus)),
	     this, SLOT(handleExit(int, QProcess::ExitStatus)) );
    tarsnap->start( field("tarsnapPath").toString() + "/tarsnap-keygen", cli );
    QByteArray pw( password->text().toUtf8() + "\n" );
    tarsnap->write( pw.data(), pw.size() );
    processStatus->setText( tr( "Running..." ) );
}
示例#30
0
文件: sample.cpp 项目: svak/ligaex
void from_demo()
{
	std::array<std::string, 9> source{
		{
			"AA", "AB", "AC",
			"BA", "BB", "BC",
			"CA", "CB", "CC"
		} };

	for (auto&w : source) {
		Dict::dict.push_back(w);
		int id = Dict::dict.size() - 1;
		std::shared_ptr<Dict::Item> pw(new Dict::Item);
		pw->word_id = id;
		Dict::words.push_back(pw);
	}
}