int main(void) { int K = 0; int N = 0, M = 0; scanf("%d", &K); while(K--) { scanf("%d%d", &N, &M); printf("%s\n", (poss(N,M)||poss(M,N))?"Yes":"No"); } return 0; }
int poss(int w, int h) { if(w < 10 && h < 10 && w*h < 6) return 0; if(w % 6) { if(0 == w%2) { return (0 == h%3); } else if (0 == w%3) { return (0 == h%2); } else return (w>6)?(poss(w%6,h)||poss(h,w%6)):0; } else { return (h>1); } }
void DateFormatRegressionTest::aux917( SimpleDateFormat *fmt, UnicodeString& str ) { //try { UnicodeString pat; pat = fmt->toPattern(pat); logln( "==================" ); logln( "testIt: pattern=" + pat + " string=" + str ); Formattable o; //Object o; ParsePosition pos(0); fmt->parseObject( str, o, pos ); //logln( UnicodeString("Parsed object: ") + o ); UErrorCode status = U_ZERO_ERROR; UnicodeString formatted; FieldPosition poss(FieldPosition::DONT_CARE); formatted = fmt->format( o, formatted, poss, status ); failure(status, "fmt->format"); logln( "Formatted string: " + formatted ); if( formatted != str) errln("Fail: Want " + str + " Got " + formatted); /*} catch (ParseException e) { errln("Fail: " + e); e.printStackTrace(); }*/ }
void addkeypressed( UINT message, WPARAM wParam, LPARAM lParam, int shift_flag, int control_flag, int alt_flag, int altgr_flag, int win_flag ) { char buffer[256], c=' ' ; int p ; if( message==WM_KEYDOWN ) c='v' ; else if( message==WM_KEYUP ) c='^' ; if( shift_flag ) shift_flag = 1 ; if( control_flag ) control_flag = 1 ; if( alt_flag ) alt_flag = 1 ; if( altgr_flag ) altgr_flag = 1 ; if( win_flag ) win_flag = 1 ; if( wParam=='\r' ) sprintf( buffer, "%d%d%d%d%d %d%c %03d(%02X)/%d (\\r)\n",shift_flag,control_flag,alt_flag,altgr_flag,win_flag, message,c, wParam, wParam, 0 ) ; else if( wParam=='\n' ) sprintf( buffer, "%d%d%d%d%d %d%c %03d(%02X)/%d (\\n)\n",shift_flag,control_flag,alt_flag,altgr_flag,win_flag, message,c, wParam, wParam, 0 ) ; else if( (wParam>=32) && (wParam<=111 ) ) sprintf( buffer, "%d%d%d%d%d %d%c %03d(%02X)/%d (%c)\n",shift_flag,control_flag,alt_flag,altgr_flag,win_flag, message,c, wParam, wParam, 0, wParam ) ; else if( (wParam>=VK_F1 /*70 112*/) && (wParam<=VK_F24 /*87 135*/) ) sprintf( buffer, "%d%d%d%d%d %d%c %03d(%02X)/%d (F%d)\n",shift_flag,control_flag,alt_flag,altgr_flag,win_flag, message,c, wParam, wParam, 0, wParam-VK_F1+1 ) ; else sprintf( buffer, "%d%d%d%d%d %d%c %03d(%02X)/%d\n",shift_flag,control_flag,alt_flag,altgr_flag,win_flag, message,c, wParam, wParam, 0 ) ; if( strlen(SaveKeyPressed) > 4000 ) { if( (p=poss("\n",SaveKeyPressed)) > 0 ) { del( SaveKeyPressed, 1, p ); } } strcat( SaveKeyPressed, buffer ) ; }
void GSA::__convertWithArrays() { std::vector<SfaType> docs(size,0); std::vector<LcpType> poss(size,0); SfaType doc = 0; LcpType pos = 0; for ( size_t i = 0; i < size; i++ ) { docs[i] = doc; poss[i] = pos; pos++; if ( concat[i] == '$' ) { doc++; pos = 0; } } Ids = new SfaType[size]; Pos = new LcpType[size]; for ( size_t i = 0; i < size; i++ ) { SfaType doc = docs[SA[i]]; LcpType pos = poss[SA[i]]; Ids[i] = doc; Pos[i] = pos; } }
/* Fonction permettant de retrouver la position d'une chaîne de caracteres dans une chaine a partir d'une position donnee */ int posi( const char * c, const char * ch, const int ipos ) { int res ; if( ( c == NULL ) || ( ch == NULL ) ) return -1 ; if( ( ipos <= 0 ) || ( (size_t) ipos > strlen( ch ) ) ) return 0 ; res = poss( c, ch + ( ipos - 1 ) ) ; if( res > 0 ) return res + ( ipos -1 ) ; else return 0 ; }
void System::testDelete() { std::vector<float4> poss(40); float4 posx(100.,100.,100.,1.); std::fill(poss.begin(), poss.end(),posx); //cl_vars_unsorted.copyToDevice(poss, max_num + 2); cl_position_u.acquire(); cl_position_u.copyToDevice(poss); cl_position_u.release(); cli->queue.finish(); }
bool imuIdentifierThread::goHome() { setHeadCtrlModes("position"); // Vector pos0(6,0.0); // iposH -> positionMove(pos0.data()); VectorOf<int> jointsToSet; jointsToSet.push_back(0); jointsToSet.push_back(1); jointsToSet.push_back(2); Vector poss(3,0.0); iposH -> positionMove(jointsToSet.size(), jointsToSet.getFirst(), poss.data()); return true; }
/*! Moves the left or top edge of the splitter handle at \a index as close as possible to position \a pos, which is the distance from the left or top edge of the widget. For right-to-left languages such as Arabic and Hebrew, the layout of horizontal splitters is reversed. \a pos is then the distance from the right edge of the widget. \sa splitterMoved(), closestLegalPosition(), getRange() */ void QSplitter::moveSplitter(int pos, int index) { Q_D(QSplitter); QSplitterLayoutStruct *s = d->list.at(index); int farMin; int min; int max; int farMax; #ifdef QSPLITTER_DEBUG int debugp = pos; #endif pos = d->adjustPos(pos, index, &farMin, &min, &max, &farMax); int oldP = d->pick(s->rect.topLeft()); #ifdef QSPLITTER_DEBUG qDebug() << "QSplitter::moveSplitter" << debugp << index << "adjusted" << pos << "oldP" << oldP; #endif QVarLengthArray<int, 32> poss(d->list.count()); QVarLengthArray<int, 32> ws(d->list.count()); bool upLeft; d->doMove(false, pos, index, +1, (d->collapsible(s) && (pos > max)), poss.data(), ws.data()); d->doMove(true, pos, index - 1, +1, (d->collapsible(index - 1) && (pos < min)), poss.data(), ws.data()); upLeft = (pos < oldP); int wid, delta, count = d->list.count(); if (upLeft) { wid = 0; delta = 1; } else { wid = count - 1; delta = -1; } for (; wid >= 0 && wid < count; wid += delta) { QSplitterLayoutStruct *sls = d->list.at( wid ); if (!sls->widget->isHidden()) d->setGeo(sls, poss[wid], ws[wid], true); } d->storeSizes(); emit splitterMoved(pos, index); }
int log_writetimestamp( struct LogContext *ctx ) { // "%m/%d/%Y %H:%M:%S " if( strlen(ctx->cfg.logtimestamp)==0 ) return 1 ; char buf[128] = "" ; if( poss( "%f", ctx->cfg.logtimestamp ) ) { SYSTEMTIME sysTime ; GetLocalTime( &sysTime ) ; t_strftime( buf, 127, ctx->cfg.logtimestamp, sysTime ) ; } else { time_t temps = time( 0 ) ; struct tm tm = * localtime( &temps ) ; m_strftime( buf, 127, ctx->cfg.logtimestamp, &tm ) ; } fwrite(buf, 1, strlen(buf), ctx->lgfp); return 1; }
void GSA::__convertWithBinarySearch() { std::vector<SfaType> poss(nreads,0); size_t doc = 0; for ( size_t i = 0; i < size; i++ ) { if ( concat[i] == '$' ) { poss[doc] = i; doc++; } } Ids = new SfaType[size]; Pos = new LcpType[size]; SfaType pos = 0; std::vector<SfaType>::iterator up; for ( size_t i = 0; i < size; i++ ) { pos = SA[i]; up = std::lower_bound( poss.begin(), poss.end(), pos ); doc = up-poss.begin(); if ( doc > 0 ) pos -= (poss[doc-1]+1); Ids[i] = doc; Pos[i] = pos; } }
int ManagePortKnocking( char* host, char *portknockseq ) { char portstr[256], protostr[256]; short port, proto ; int i,j; if( (host==NULL) || (portknockseq==NULL) ) return 0 ; if( (strlen(host)==0) || (strlen(portknockseq)==0) ) return 0 ; for(i=0;i<strlen(portknockseq);i++) { if( (portknockseq[i]==' ')||(portknockseq[i]==' ')||(portknockseq[i]==';')||(portknockseq[i]=='-') ) portknockseq[i]=','; } while( portknockseq[0]==',' ) del(portknockseq,1,1); while( portknockseq[strlen(portknockseq)-1]==',' ) portknockseq[strlen(portknockseq)-1]='\0'; while( (i=poss(",:",portknockseq)) ) { del(portknockseq,i,1); } while( (i=poss(":,",portknockseq)) ) { del(portknockseq,i+1,1); } while( (i=poss(",,",portknockseq)) ) { del(portknockseq,i,1); } while( strlen(portknockseq)>0 ) { while( (portknockseq[0]==' ')||(portknockseq[0]==' ')||(portknockseq[0]==',')||(portknockseq[0]==';') ) del(portknockseq,1,1); if( strlen(portknockseq)>0 ) { i=poss(":",portknockseq) ; if(i==0) i=strlen(portknockseq)+1; j=poss(",",portknockseq) ; if(j==0) j=strlen(portknockseq)+1; if(j<i) i=j; strcpy(portstr,portknockseq); if( portstr[i-1]!=':' ) { portstr[i-1]='\0'; del(portknockseq,1,i); strcpy(protostr,"tcp"); } else { portstr[i-1]='\0'; del(portknockseq,1,i); i=poss(",",portknockseq) ; if(i==0) i=strlen(portknockseq)+1; strcpy(protostr,portknockseq); protostr[i-1]='\0'; del(portknockseq,1,i); } port=atoi(portstr); if( !stricmp(protostr,"udp") ) proto=PROTO_UDP ; else proto=PROTO_TCP ; if( !stricmp(protostr,"s") ) Sleep(port*1000); else if( knock(host,port,proto) ) logevent( NULL, "Unable to knock port" ); } } return 1; }
void Density::execute(int num, //input //Buffer<float4>& svars, Buffer<float4>& pos_s, Buffer<float>& dens_s, //output Buffer<unsigned int>& ci_start, Buffer<unsigned int>& ci_end, //params Buffer<SPHParams>& sphp, Buffer<GridParams>& gp, //debug params Buffer<float4>& clf_debug, Buffer<int4>& cli_debug) { int iarg = 0; //k_density.setArg(iarg++, svars.getDevicePtr()); k_density.setArg(iarg++, pos_s.getDevicePtr()); k_density.setArg(iarg++, dens_s.getDevicePtr()); k_density.setArg(iarg++, ci_start.getDevicePtr()); k_density.setArg(iarg++, ci_end.getDevicePtr()); k_density.setArg(iarg++, gp.getDevicePtr()); k_density.setArg(iarg++, sphp.getDevicePtr()); // ONLY IF DEBUGGING k_density.setArg(iarg++, clf_debug.getDevicePtr()); k_density.setArg(iarg++, cli_debug.getDevicePtr()); int local = 64; try { float gputime = k_density.execute(num, local); if(gputime > 0) timer->set(gputime); } catch (cl::Error er) { printf("ERROR(density): %s(%s)\n", er.what(), CL::oclErrorString(er.err())); } #if 0 //printouts //DEBUGING if(num > 0)// && choice == 0) { printf("============================================\n"); printf("which == %d *** \n", choice); printf("***** PRINT neighbors diagnostics ******\n"); printf("num %d\n", num); std::vector<int4> cli(num); std::vector<float4> clf(num); cli_debug.copyToHost(cli); clf_debug.copyToHost(clf); std::vector<float4> poss(num); std::vector<float4> dens(num); for (int i=0; i < num; i++) //for (int i=0; i < 10; i++) { //printf("-----\n"); printf("clf_debug: %f, %f, %f, %f\n", clf[i].x, clf[i].y, clf[i].z, clf[i].w); //if(clf[i].w == 0.0) exit(0); //printf("cli_debug: %d, %d, %d, %d\n", cli[i].x, cli[i].y, cli[i].z, cli[i].w); // printf("pos : %f, %f, %f, %f\n", pos[i].x, pos[i].y, pos[i].z, pos[i].w); } } #endif }
/* * translate format codes into time/date strings * and insert them into log file name * * "&Y":YYYY "&m":MM "&d":DD "&T":hhmmss "&h":<hostname> "&&":& */ static void xlatlognam(Filename *dest, Filename src, char *hostname, struct tm *tm) { #ifdef PERSOPORT char buf[100], *bufp; #else char buf[10], *bufp; #endif int size; char buffer[FILENAME_MAX]; int len = sizeof(buffer)-1; char *d; const char *s; d = buffer; s = filename_to_str(&src); while (*s) { /* Let (bufp, len) be the string to append. */ bufp = buf; /* don't usually override this */ if (*s == '&') { char c; s++; size = 0; if (*s) switch (c = *s++, tolower((unsigned char)c)) { case 'y': size = strftime(buf, sizeof(buf), "%Y", tm); break; case 'm': size = strftime(buf, sizeof(buf), "%m", tm); break; case 'd': size = strftime(buf, sizeof(buf), "%d", tm); break; case 't': size = strftime(buf, sizeof(buf), "%H%M%S", tm); break; case 'h': #ifdef PERSOPORT strcpy(buf,hostname) ; int i ; while( (i=poss(":",buf))>0 ) { buf[i-1]='-' ; } bufp=buf ; #else bufp = hostname; #endif size = strlen(bufp); break; default: buf[0] = '&'; size = 1; if (c != '&') buf[size++] = c; } } else { buf[0] = *s++; size = 1; } if (size > len) size = len; memcpy(d, bufp, size); d += size; len -= size; } *d = '\0'; *dest = filename_from_str(buffer); }
/* * translate format codes into time/date strings * and insert them into log file name * * "&Y":YYYY "&m":MM "&d":DD "&T":hhmmss "&h":<hostname> "&&":& */ static Filename *xlatlognam(Filename *src, char *hostname, int port, struct tm *tm) { #ifdef PERSOPORT char buf[100], *bufp; #else char buf[32], *bufp; #endif int size; char *buffer; int buflen, bufsize; const char *s; Filename *ret; bufsize = FILENAME_MAX; buffer = snewn(bufsize, char); buflen = 0; s = filename_to_str(src); while (*s) { int sanitise = FALSE; /* Let (bufp, len) be the string to append. */ bufp = buf; /* don't usually override this */ if (*s == '&') { char c; s++; size = 0; if (*s) switch (c = *s++, tolower((unsigned char)c)) { case 'y': size = strftime(buf, sizeof(buf), "%Y", tm); break; case 'm': size = strftime(buf, sizeof(buf), "%m", tm); break; case 'd': size = strftime(buf, sizeof(buf), "%d", tm); break; case 't': size = strftime(buf, sizeof(buf), "%H%M%S", tm); break; #ifdef PERSOPORT case 'h': strcpy(buf,hostname) ; int i ; while( (i=poss(":",buf))>0 ) { buf[i-1]='-' ; } // Pour gerer IPv6 bufp=buf ; #else case 'h': bufp = hostname; #endif size = strlen(bufp); break; case 'p': size = sprintf(buf, "%d", port); break; default: buf[0] = '&'; size = 1; if (c != '&') buf[size++] = c; } /* Never allow path separators - or any other illegal * filename character - to come out of any of these * auto-format directives. E.g. 'hostname' can contain * colons, if it's an IPv6 address, and colons aren't * legal in filenames on Windows. */ sanitise = TRUE; } else { buf[0] = *s++; size = 1; } if (bufsize <= buflen + size) { bufsize = (buflen + size) * 5 / 4 + 512; buffer = sresize(buffer, bufsize, char); } while (size-- > 0) { char c = *bufp++; if (sanitise) c = filename_char_sanitise(c); buffer[buflen++] = c; } }
/* * translate format codes into time/date strings * and insert them into log file name * * "&Y":YYYY "&m":MM "&d":DD "&T":hhmmss "&h":<hostname> "&&":& */ static Filename *xlatlognam(Filename *src, char *hostname, struct tm *tm) { #ifdef PERSOPORT char buf[100], *bufp; #else char buf[10], *bufp; #endif int size; char *buffer; int buflen, bufsize; const char *s; Filename *ret; bufsize = FILENAME_MAX; buffer = snewn(bufsize, char); buflen = 0; s = filename_to_str(src); while (*s) { /* Let (bufp, len) be the string to append. */ bufp = buf; /* don't usually override this */ if (*s == '&') { char c; s++; size = 0; if (*s) switch (c = *s++, tolower((unsigned char)c)) { case 'y': size = strftime(buf, sizeof(buf), "%Y", tm); break; case 'm': size = strftime(buf, sizeof(buf), "%m", tm); break; case 'd': size = strftime(buf, sizeof(buf), "%d", tm); break; case 't': size = strftime(buf, sizeof(buf), "%H%M%S", tm); break; case 'h': #ifdef PERSOPORT strcpy(buf,hostname) ; int i ; while( (i=poss(":",buf))>0 ) { buf[i-1]='-' ; } bufp=buf ; #else bufp = hostname; #endif size = strlen(bufp); break; default: buf[0] = '&'; size = 1; if (c != '&') buf[size++] = c; } } else { buf[0] = *s++; size = 1; } if (bufsize <= buflen + size) { bufsize = (buflen + size) * 5 / 4 + 512; buffer = sresize(buffer, bufsize, char); } memcpy(buffer + buflen, bufp, size); buflen += size; }
void RigidBodyForce::execute(int num, Buffer<float>& density, Buffer<float4>& pos_s, Buffer<float4>& veleval_s, Buffer<float4>& force_s, Buffer<float>& mass_s, Buffer<float4>& rb_pos_s, Buffer<float4>& rb_velocity_s, Buffer<float>& rb_mass_s, Buffer<unsigned int>& ci_start, Buffer<unsigned int>& ci_end, //params Buffer<SPHParams>& sphp, Buffer<GridParams>& gp, float stiffness, float dampening, float friction_dynamic, float friction_static, float friction_static_threshold, //debug params Buffer<float4>& clf_debug, Buffer<int4>& cli_debug) { int iarg = 0; k_rigidbody_force.setArg(iarg++, density.getDevicePtr()); k_rigidbody_force.setArg(iarg++, pos_s.getDevicePtr()); k_rigidbody_force.setArg(iarg++, veleval_s.getDevicePtr()); k_rigidbody_force.setArg(iarg++, force_s.getDevicePtr()); k_rigidbody_force.setArg(iarg++, mass_s.getDevicePtr()); k_rigidbody_force.setArg(iarg++, rb_pos_s.getDevicePtr()); k_rigidbody_force.setArg(iarg++, rb_velocity_s.getDevicePtr()); k_rigidbody_force.setArg(iarg++, rb_mass_s.getDevicePtr()); float16 rbParams; rbParams.m[0]=stiffness; rbParams.m[1]=dampening; rbParams.m[2]=friction_dynamic; rbParams.m[3]=friction_static; rbParams.m[4]=friction_static_threshold; k_rigidbody_force.setArg(iarg++, rbParams); k_rigidbody_force.setArg(iarg++, ci_start.getDevicePtr()); k_rigidbody_force.setArg(iarg++, ci_end.getDevicePtr()); k_rigidbody_force.setArg(iarg++, gp.getDevicePtr()); k_rigidbody_force.setArg(iarg++, sphp.getDevicePtr()); // ONLY IF DEBUGGING k_rigidbody_force.setArg(iarg++, clf_debug.getDevicePtr()); k_rigidbody_force.setArg(iarg++, cli_debug.getDevicePtr()); int local = 64; try { float gputime = k_rigidbody_force.execute(num, local); if(gputime > 0) timer->set(gputime); } catch (cl::Error er) { printf("ERROR(rigidbody force ): %s(%s)\n", er.what(), CL::oclErrorString(er.err())); } #if 0 //printouts //DEBUGING if(num > 0)// && choice == 0) { printf("============================================\n"); printf("which == %d *** \n", choice); printf("***** PRINT neighbors diagnostics ******\n"); printf("num %d\n", num); std::vector<int4> cli(num); std::vector<float4> clf(num); cli_debug.copyToHost(cli); clf_debug.copyToHost(clf); std::vector<float4> poss(num); std::vector<float4> dens(num); for (int i=0; i < num; i++) //for (int i=0; i < 10; i++) { //printf("-----\n"); printf("clf_debug: %f, %f, %f, %f\n", clf[i].x, clf[i].y, clf[i].z, clf[i].w); //if(clf[i].w == 0.0) exit(0); //printf("cli_debug: %d, %d, %d, %d\n", cli[i].x, cli[i].y, cli[i].z, cli[i].w); //printf("pos : %f, %f, %f, %f\n", pos[i].x, pos[i].y, pos[i].z, pos[i].w); } } #endif }