void dfs(int p, int now) { F[now].ok = 0; deal(p, F[now].b, F[now].a); deal(p, F[now].c, F[now].b); deal(p, F[now].a, F[now].c); }
std::vector<Triangle> getConvex(std::vector<TPoint> &p) { static std::vector<Triangle> ret; ret.clear(); nFace = 0; if(!init(p)) return ret; if (!isVisible(p, Face(0, 1, 2), p[3])) pushface(0, 1, 2); else pushface(0, 2, 1); if (!isVisible(p, Face(0, 1, 3), p[2])) pushface(0, 1, 3); else pushface(0, 3, 1); if (!isVisible(p, Face(0, 2, 3), p[1])) pushface(0, 2, 3); else pushface(0, 3, 2); if (!isVisible(p, Face(1, 2, 3), p[0])) pushface(1, 2, 3); else pushface(1, 3, 2); for (int a = 4; a < (int)p.size(); a++) { TPoint base = p[a]; for (int i = 1; i <= nFace; i++) { if (tmp[i].isOnConvex && isVisible(p, tmp[i], base)) { left = 0, right = 0; queue[++right] = tmp[i]; tmp[i].isOnConvex = false; while (left < right) { Face now = queue[++left]; if (!deal(p, std::make_pair(now.a, now.b), base)) pushface(now.a, now.b, a); if (!deal(p, std::make_pair(now.b, now.c), base)) pushface(now.b, now.c, a); if (!deal(p, std::make_pair(now.c, now.a), base)) pushface(now.c, now.a, a); } break; } } } for (int i = 1; i <= nFace; i++) { Face now = tmp[i]; if (now.isOnConvex) { ret.push_back(Triangle(p[now.a], p[now.b], p[now.c])); } } return ret; }
void dfs(int p, int now) { //Recursive search of all should be removed from //the inner surface of the convex hull F[now].ok = 0; deal(p, F[now].b, F[now].a); deal(p, F[now].c, F[now].b); deal(p, F[now].a, F[now].c); }
void down(int root, LL L, LL R) { if(!nodes[root].vis) return; LL mid = (L + R) >> 1; int &l = nodes[root].l, &r = nodes[root].r; if(l == -1) l = newNode(); if(r == -1) r = newNode(); deal(l, L, mid); deal(r, mid + 1, R); }
int main() { freopen("ratios.in", "r", stdin), freopen("ratios.out","w", stdout); read(); deal(); fclose(stdin), fclose(stdout); }
int main() { int all,maxx,maxy,i,j; #ifndef __GNUC__ freopen("D:\\std.txt","r",stdin); #endif scanf("%d",&all); for(;all>0;all--) { scanf("%d %d%*c",&maxx,&maxy); reset_map(maxx,maxy); for(i=0;i<maxx;i++) { memset(buff,0,128); gets(buff); for(j=0;j<maxy;j++) { if(buff[j]=='0') { map[i+1][j+1]=0; } else { map[i+1][j+1]=1; } } } deal(maxx,maxy); } return 0; }
void Briscola::play(){ cout << "-- Debut de manche --" << endl; int iBest = players.getActualPlayerId(); for(int i = 0; i < 3; i++){ cout << "Atout : " << *last << endl; do{ oneAction(); players.next(); } while (players.getActualPlayerId() != iBest); cout << "\nTable : " << *discardPiles << endl; CardContainer cards = discardPiles->removeAll(); iBest = 0; Card& best = cards.getElement(cards.getSize() -1); for(int i = 0; i < cards.getSize() -1; i++) if(best.compare(cards.getElement(i), settings)<0){ best = cards.getElement(i); iBest = i; } players.discardTo(iBest, cards); players.setActualPlayer(iBest); cout << "Best : " << best << endl; } deal(); }
void start() { char a; char choice=0; int i=0; rules(); printf("Aby rozpoczac losowanie, wpisz 1: "); while(a=getchar()) { if(i==0) { if(a=='1') choice = a; else choice = 0; i++; } else { if(choice&&i==1&&a=='\n') deal(); else if (a=='\n') { printf("Niewlasciwa komenda!\n"); i=0; } else i++; }/*else*/ if(choice=='1'&&a=='\n'&&i==1) break; } }/*start()*/
/* * playhand: * Do up one hand of the game */ int playhand(bool mycrib) { int deckpos; werase(Compwin); wrefresh(Compwin); werase(Tablewin); wrefresh(Tablewin); knownum = 0; deckpos = deal(mycrib); sorthand(chand, FULLHAND); sorthand(phand, FULLHAND); makeknown(chand, FULLHAND); prhand(phand, FULLHAND, Playwin, FALSE); discard(mycrib); if (cut(mycrib, deckpos)) return TRUE; if (peg(mycrib)) return TRUE; werase(Tablewin); wrefresh(Tablewin); if (score(mycrib)) return TRUE; return FALSE; }
int main() { /* initialize suit array */ const char *suit[ 4 ] = { "Hearts", "Diamonds", "Clubs", "Spades" }; /* initialize face array */ const char *face[ 13 ] = { "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace" }; const char *names[ 9 ] = { "High card", "Pair", "Two Pair", "Three of a kind", "Straight", "Flush", "Full house", "Four of a kind", "Straight Flush" }; int hand1, hand2; /* initialize deck array */ int deck[ 4 ][ 13 ] = { 0 }; int Hands[10] = { 0 }; int Decks[2][5][2]; srand( time( 0 ) ); /* seed random-number generator */ int Decks2[2][5][2] ={ { {2, 2},{3, 2},{8, 2},{12, 2},{9, 2} }, { {12, 1},{8, 3},{9, 3},{10, 1},{11, 2} } }; shuffle( deck ); deal( deck, face, suit, Decks); printDeal(Decks, face, suit); evaluate_hand(Decks, Hands, names); //getchar(); return 0; /* indicates successful termination */ } /* end main */
static int run() { fd_set socket_fd_set; fd_set tmp_fd_set; struct timeval t; int nfds; int fd; FD_ZERO(&socket_fd_set); FD_SET(socket_fd, &socket_fd_set); while (1) { tmp_fd_set = socket_fd_set; t.tv_sec = CHECK_INTERVAL_S; t.tv_usec = 0; nfds = select(FD_SETSIZE, &tmp_fd_set, NULL, NULL, &t); if (nfds > 0) { for (fd = 0; fd < FD_SETSIZE; ++ fd) { if (FD_ISSET(fd, &tmp_fd_set)) deal(fd, &socket_fd_set); } } } return 1; }
QStringList xmldealer::find(QString tag,QString context) { result.clear(); while(!filereader.atEnd()) { filereader.readNext(); if(filereader.isStartElement()) { if(!deal(tag,context)) return result; } else if(filereader.hasError()) { qDebug()<<"xml read error:"<<filereader.errorString(); result.clear(); return result; } else if(filereader.atEnd()) { qDebug()<<"xml read done"; return result; } } result.clear(); return result; }
__int64 deal(int k) { if(k==0) return 1; if(k%2==0) { __int64 temp=deal(k/2); return (temp*temp)%n; } else { __int64 temp=deal((k-1)/2); __int64 ans=(((temp*temp)%n)*(2%n))%n; return ans; } }
int main (){ int i; for (i=1;i<=1000;i++) printf ("num=%d sum=%d\n",i,deal(i)); return 0; }
void Fortyeight::restart() { lastdeal = false; Deck::deck()->collectAndShuffle(); deal(); emit newCardsPossible( true ); }
bool Bianbian::init() { this->_HurtValue = 1024.0f; this->_BaseScale = 0.6f; this->_InValidTime = 2.5f; this->setTag(ELEMENT_WEAPON_TAG); this->setName(WEAPON_BIANBIAN_NAME); _WeaponType = WeaponType::Hulu; _WeaponMoveWays = WeaponMoveWays::Vertical; _Sprite = Sprite::createWithTexture(TextureCache::getInstance()->addImage("Images/bigBian.png")); this->addChild(_Sprite); auto breathAction = RepeatForever::create(Sequence::create( ScaleTo::create(1.0f, 1.2f*_BaseScale), ScaleTo::create(1.0f, 1.0f*_BaseScale), NULL )); breathAction->setTag(ACTION_TAG_BREATH); _Sprite->runAction(breathAction); if (this->_InValidTime > 0) { auto invalidAction = Sequence::create(DelayTime::create(_InValidTime), CallFunc::create([=](){ deal(this); }), NULL); this->runAction(invalidAction); } _EnemyDieType = EnemyDieType::ScaleDown; initElement(); return true; }
int main() { char s[10]; int i,j,ans; memset(v,1,sizeof(v)); for(i=1;i<=8;i++) { scanf("%s",s); for(j=0;j<8;j++) { if(s[j]=='S') { deal(i,j+1); } } } // system("pause"); ans=BFS(); if(ans==-1) printf("LOSE\n"); else printf("WIN\n"); return 0; }
int main ( void ) { Card deck[ 52 ]; /* create array of Cards */ fillDeck( deck ); deal( deck ); return 0; } /* end main */
int main( void ) { Card deck[ 52 ]; /* create array of Cards */ fillDeck( deck ); deal( deck ); return 0; /* indicates successful termination */ } /* end main */
ModuleFourDialog::ModuleFourDialog(QWidget *parent) : QDialog(parent) { ui = new Ui_ModuleFourDialog; ui->setupUi(this); connect(ui->okButton, SIGNAL(clicked()), this, SLOT(deal())); connect(ui->setLineEdit, SIGNAL(textEdited(QString)), this, SLOT(clearText(QString))); connect(ui->RLineEdit, SIGNAL(textEdited(QString)), this, SLOT(clearText(QString))); }
void deal_cards() { int i; for (i=0; i<10; i++) { deal(testgame, i); } }
int countNodes(struct TreeNode* root) { if (root==NULL) return 0; exist=false; maxn=-1; DFS(root,0); deal(); return ans; }
void server_download(int conn_fd, const char * pathname, char * len) { int fd; char buf[SIZE]; char choose[SIZE]; int ret; int lenght = 0; int sum = 0; int flag; int i = 0; char tmp[SIZE]; long r_len; char log[SIZE]; if ((fd = open(pathname, O_RDONLY)) == -1) { strcpy(log, pathname); strcat(log, " 下载失败"); sys_log(log); return ; } strcpy(log, " 文件名:"); strcat(log, pathname); strcat(log, " 下载文件大小:"); strcat(log, len); sys_log(log); send_data(conn_fd, len); recv(conn_fd, tmp, sizeof(tmp), 0); r_len = atol(tmp); lseek(fd, r_len, SEEK_SET); while (1) { flag = read(fd, buf, SIZE); sum += flag; ret = send(conn_fd, buf, flag, 0); if (flag != SIZE) { break; } } close (fd); memset(log, '\0', sizeof(log)); strcpy(log, " 下载成功,"); my_recv(conn_fd, buf, sizeof(buf)); if (buf[0] == 'y') { sys_log(" 用户返回选择界面 "); deal(conn_fd); } else { return ; } }
int main() { while(scanf("%d",&n)!=EOF) { if(!n)break; printf("%d\n",(deal(n-1)+(1%n))%n); } return 0; }
int deal (int i){ int s=0,res; if (!(i/10)) return i; while(i){ s+=i%10; i/=10; } res=deal(s); return res; }
void conditionalDeal(Node& thisNode, Stage refStage, Stage compareStage, std::vector<int> &deck, Stage stage) { if (refStage != compareStage) { std::vector<int> dealtCards = deal(deck, refStage); for (int i: dealtCards) thisNode.getGame().getBoardCards().push_back(i); } else { //std::cout << "comparestage: " << compareStage << std::endl; //std::cout << "refstage: " << refStage << std::endl; } }
int start_server() { int socketfd; int socketfd_cli; struct sockaddr_in address; struct sockaddr_in address_cli; int len; int ret; //char c; signal(SIGCHLD, SIG_IGN); /* 忽略子进程结束信息,避免不wait后出现僵尸进程 */ unlink(SERVER_SOCK); socketfd = socket(AF_INET, SOCK_STREAM, 0); address.sin_family = AF_INET; address.sin_addr.s_addr = inet_addr("127.0.0.1"); address.sin_port = htons(PORT); /* 将端口号的整数字节序转换成网络字节序 */ ret = bind(socketfd, (struct sockaddr*)&address, sizeof(address)); if (ret == -1) { perror("bind"); return 0; } listen(socketfd, 5); setnonblock(&socketfd); while (1) { len = sizeof(address_cli); socketfd_cli = accept(socketfd, (struct sockaddr*)&address_cli, (socklen_t*)&len); if (socketfd_cli != -1) { if (fork() == 0) { deal(socketfd_cli); close(socketfd_cli); sleep(5); exit(EXIT_SUCCESS); } else { close(socketfd_cli); } } else { //perror("accept"); } } close(socketfd); return 1; }
/*on pressing Deal button this function starts the hand and displays the hands of both *dealer and player*/ void cb_deal(GtkWidget *widget, gpointer data) { config *c; c = (config *)data; if(c->p->money > 5000000) return; gtk_label_set_text(c->result, ""); deal(c->p, c->d, c->s, c->grid1, c->grid2); dealdispplayer(c->p, c->grid2); dealdisplay(c->d, c->grid1); gtk_widget_show_all((GtkWidget *)c->window); }
int main() { void input(int *); void deal(int *); void output(int *); int x[10]; input(x); deal(x); output(x); return 0; }
int main() { int Q, t, p, A, B; long min0, min1, D1, D2; int i, j, k; scanf("%d", &Q); while (Q--) { memset(g, false, sizeof(g)); scanf("%d %d", &n, &t); while (t--) { scanf("%s %d", &buff, &p); deal(0); if (p) { deal(1); } }/* for (i = 0; i < 2; i++) { for (j = 1; j <= n; j++) { for (k = 1; k <= n; k++) { printf("%d ", g[i][j][k]); } printf("\n"); } printf("\n"); }*/ scanf("%d %d", &D1, &D2); scanf("%d %d", &A, &B); min0 = run(0, A, B); min1 = run(1, A, B); if (min0 < 0 && min1 < 0) { printf("-1\n"); }else if (min0 < 0) { printf("%ld\n", min1*D2); }else if (min1 < 0) { printf("%ld\n", min0*D1); }else if (min0*D1 < min1*D2) { printf("%ld\n", min0*D1); }else{ printf("%ld\n", min1*D2); } } }