void ins(char c[50], char sc[20]) { int i, j = 0, k = 0, l, m = 0, x, p,n,g; char s; for (i = 0; c[i] != '\0'; i++) j = j + 1; for (i = 0; sc[i] != '\0'; i++) k = k + 1; if (k % 2 != 0) printf("insertion not possible"); m=satisfy(sc,k/2, k); g=check(c, j); if ((m == k / 2) && (g == 1)) { x = j + k; l = k; for (i = x; i >= x - k / 2; i--) { sc[i] = sc[l]; l--; } p = 0; x = j + k; for (i = k / 2; i < x - k / 2; i++) { sc[i] = c[p]; p++; } for (i = 0; i < x; i++) printf("%c", sc[i]); } else printf("not possible"); }
int check(char c[50],int len) { int i, j=0, k; if (((c[0] >= 'a') && (c[0] <= 'z')) || ((c[0] >= '0') && (c[0] <= '9')) || ((c[0] >= 'A') && (c[0] <= 'Z'))) { if (!(((c[len - 1] >= 'a') && (c[len - 1] <= 'z')) || ((c[len - 1] >= '0') && (c[len - 1] <= '9')) || ((c[len - 1] >= 'A') && (c[len - 1] <= 'Z')))) return(0); } else { for (i = 0; c[i] != '\0'; i++) { if (((c[i] >= 'a') && (c[i] <= 'z')) || ((c[i] >= '0') && (c[i] <= '9')) || ((c[i] >= 'A') && (c[i] <= 'Z'))) { j = i; break; } } if (!(((c[j - 1] >= 'a') && (c[j - 1] <= 'z')) || ((c[j - 1] >= '0') && (c[j - 1] <= '9')))) k = satisfy(c, j, len); if (k == j) return(1); else return(0); } }
void move(int threshold, int rows, int cols, int row, int col, int& result, vector<vector<bool>>& miniMap) { if(!satisfy(threshold, row, col) || row < 0 || col < 0 || row >= rows || col >= cols || miniMap[row][col] == false) return; result++; miniMap[row][col] = false; move(threshold, rows, cols, row+1, col, result, miniMap); move(threshold, rows, cols, row-1, col, result, miniMap); move(threshold, rows, cols, row, col+1, result, miniMap); move(threshold, rows, cols, row, col-1, result, miniMap); return; }
bool SecRuleRelative::satisfy (const Data& data) { Name dataName = data.getName(); try{ SignatureSha256WithRsa sig(data.getSignature()); Name signerName = sig.getKeyLocator().getName (); return satisfy (dataName, signerName); }catch(SignatureSha256WithRsa::Error &e){ return false; }catch(KeyLocator::Error &e){ return false; } }
void IncSolver::solve() { #ifdef RECTANGLE_OVERLAP_LOGGING ofstream f(LOGFILE,ios::app); f<<"solve_inc()..."<<endl; #endif double lastcost,cost = bs->cost(); do { lastcost=cost; satisfy(); splitBlocks(); cost = bs->cost(); #ifdef RECTANGLE_OVERLAP_LOGGING f<<" cost="<<cost<<endl; #endif } while(fabs(lastcost-cost)>0.0001); }
int main() { int m,ans=0,mod=1000000007,test; scanf("%d",&test); while(test--){ ans=0; scanf("%s%d",A,&m); int len=strlen(A); for(int a=0;a<len;a++) for(int b=a;b<len;b++) for(int c=b+1;c<len;c++) for(int d=c;d<len;d++) for(int e=d+1;e<len;e++) for(int f=e;f<len;f++){ if(check(a,b,c,d) && check(a,b,e,f) && check(c,d,e,f)) break; ans=(ans+satisfy(a,b,c,d,e,f,m))%mod; } printf("%d\n",ans); } return 0; }
/** * Calculate the optimal solution. After using satisfy() to produce a * feasible solution, refine() examines each block to see if further * refinement is possible by splitting the block. This is done repeatedly * until no further improvement is possible. */ void Solver::solve() { satisfy(); refine(); }