int main() { ll high,cur,g,teller,nevner; int cases,i,j,highs; scanf("%d",&cases); while(cases--) { scanf("%d %d",&n,&str); for(i=0;i<str;i++) for(j=0;j<n;j++) scanf("%d",&st[i][j]); for(i=0;i<str;i++) for(j=0;j<n;j++) guess[i][j]=simul(i,j); high=highs=-1; for(i=0;i<n;i++) { cur=0; for(j=0;j<str;j++) cur+=guess[j][i]; if(cur>high) { high=cur; highs=i; } } g=gcd(high,str); teller=high/g; nevner=str/g; printf("%I64d/%I64d\n",teller,nevner); for(i=0;i<n;i++) printf("%d ",highs==i?str:0); printf("\n"); } return 0; }
main () { char filename[200]; FILE *f; float x; int i; int driver, mode, status; out = fopen ("out.lis", "w"); if (out == NULL) { perror ("out.lis"); out = stdout; } /* printf ("Fichier cours? "); gets (filename); f = fopen (filename, "r"); if (f == NULL) { perror (filename); return; } for (i=0; i<MAX; i++) { if (feof(f)) break; fscanf (f, "%f", &x); cours[i] = x; } n = i; */ n = sizeof (cours) / sizeof (cours[0]); for (i=0; i<n; i++) { printf ("%04d : %4.2f\n", i, cours[i]); } /* driver = DETECT; mode = 0; initgraph (&driver, &mode, "c:\\tc"); status = graphresult (); if (status != grOk) printf ("Erreur initgraph %d 0x%X\n", status, status); for (i=0; i<n; i++) putpixel (i+1, (260-cours[i])*10, 1); restorecrtmode (); */ simul (); }
int main() { exp_arrival arr(2.0); ring buf(5); std::vector<exp_server> exp_srvrs {exp_server(1, 1.0), exp_server(2, 1.0)}; std::vector<server*> srvrs(exp_srvrs.size()); auto p = srvrs.begin(); for (auto q = exp_srvrs.begin(); p != srvrs.end(); p++, q++) { *p = exp_srvrs.data() + (q - exp_srvrs.begin()); } minheap_service srv(srvrs); simulation simul(arr, buf, srv); int n = 100000000; int nrej = count_rejs(simul, n); std::cout << "ratio: " << (double) nrej / n << std::endl; }
void mainloop() { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glutWireSphere(c_Re,20,10); glutWireSphere(c_Rgeo,20,10); glBegin(GL_LINE_STRIP); for(int i = 0; i < numpoints; i++) { if(i > 0 && points[i - 1].k == 0) { glEnd(); glBegin(GL_LINE_STRIP); } glVertex3d(points[i].pos.x, points[i].pos.y, points[i].pos.z); } glEnd(); glutSwapBuffers(); for(int i = 0; i < 600; i++) { simul(); } }
/*! * Options de la ligne de commande : * * <dl> * <dt>-d</dt><dd>mode pas à pas (mise au point)</dd> * * <dt>-f</dt><dd>le programme est dans un fichier binaire ; le nom de ce * fichier doit être fourni également en paramètre de la ligne de * commande ; sans cette option, on exécute un programme de test prédéfini.</dd> * * </dl> */ int main(int argc, char *argv[]) { bool debug = false; bool binfile = false; bool no_exec = false; char *programfile = NULL; if (argc > 1) { for (int iarg = 1; iarg < argc; ++iarg) { if (argv[iarg][0] == '-') switch (argv[iarg][1]) { case 'd': debug = true; break; case 'b': binfile = true; break; case 'l': no_exec = true; break; case 'h': usage(); exit(EXIT_SUCCESS); default: fprintf(stderr, "Unknown option: %s\n", argv[iarg]); usage(); exit(EXIT_FAILURE); } else if (binfile) programfile = argv[iarg]; else fprintf(stderr, "Trailing options ignored...\n"); } } Machine mach; if (!binfile) load_program(&mach, textsize, text, datasize, data, dataend); else read_program(&mach, programfile); printf("\n*** Sauvegarde des programmes et données initiales en format binaire ***\n\n"); dump_memory(&mach); printf("\n*** Machine state before execution ***\n"); print_program(&mach); print_data(&mach); print_cpu(&mach); if (no_exec) return 0; printf("\n*** Execution trace ***\n\n"); simul(&mach, debug); printf("\n*** Machine state after execution ***\n"); print_cpu(&mach); print_data(&mach); if(allocated){ free(mach._text); free(mach._data); } return 0; }
main () { char filename[200]; FILE *f; float x; int i; int driver, mode, status; float c, d; out = fopen ("out.lis", "w"); if (out == NULL) { perror ("out.lis"); out = stdout; } /* printf ("Fichier cours? "); gets (filename); f = fopen (filename, "r"); if (f == NULL) { perror (filename); return; } for (i=0; i<MAX; i++) { if (feof(f)) break; fscanf (f, "%f", &x); cours[i] = x; } n = i; */ /* n = sizeof (cours) / sizeof (cours[0]); */ /* for (i=0; i<n; i++) { printf ("%04d : %4.2f\n", i, cours[i]); } */ /* driver = DETECT; mode = 0; initgraph (&driver, &mode, "c:\\tc"); status = graphresult (); if (status != grOk) printf ("Erreur initgraph %d 0x%X\n", status, status); for (i=0; i<n; i++) putpixel (i+1, (8-cours[i])*100, 10); restorecrtmode (); */ /* for (d=0.001; d<0.1; d*=1.1) simul (d); */ for (i=0; i<sizeof(tab_cours)/sizeof(tab_cours[0]); i++) { printf ("\n%s\n", tab_cours[i].nom); for (c=1000/Euro; c<2000000/Euro; c*=2) simul (0.045, c, tab_cours+i); } fflush (out); }
static int simulation() { int i; double kchi2, kg2, kprob; // double p1,p2; int x2_file; char nimi[LNAME]; i=rand_init(); if (i<0) return(-1); make_samples(); x2_file=0; i=spfind("X2FILE"); if (i>=0) { strcpy(nimi,spb[i]); if (!muste_is_path(nimi)) { strcpy(nimi,edisk); strcat(nimi,spb[i]); } tied=muste_fopen(nimi,"wt"); if (tied==NULL) { sprintf(sbuf,"\nCannot open %s for X^2 values!",nimi); sur_print(sbuf); WAIT; return(-1); } x2_file=1; } dn=10000L; i=spfind("GAP"); if (i>=0) dn=atol(spb[i]); count=0L; pcount=0L; dcount=0L; ecount=0L; while (1) { ++count; ++dcount; switch (fix) { case FISHER: case FIX_RC: permutoi(total,sample2); taulukoi(sample1,sample2,f); if (test==PROB) { c_prob(&kprob,f); if (kprob>=prob) ++pcount; } else if (test==X2) { c_chi2(&kchi2,f); if (kchi2>=chi2) ++pcount; } else { c_g2(&kg2,f); if (kg2>=g2) ++pcount; } break; case FIX_C: simul(total,m,sample1,cum_r); taulukoi(sample1,sample2,f); if (test==PROB) { c_cprob(&kprob,f); if (kprob>=prob) { ++pcount; if (x2_file) { c_chi2(&kchi2,f); fprintf(tied,"%g\n",kchi2); } } } else if (test==X2) { c_chi2(&kchi2,f); if (kchi2>=chi2) ++pcount; } else { c_g2(&kg2,f); if (kg2>=g2) ++pcount; } break; case FIX_R: simul(total,n,sample2,cum_c); taulukoi(sample1,sample2,f); if (test==PROB) { c_rprob(&kprob,f); if (kprob>=prob) { ++pcount; if (x2_file) { c_chi2(&kchi2,f); fprintf(tied,"%g\n",kchi2); } } } else if (test==X2) { c_chi2(&kchi2,f); if (kchi2>=chi2) ++pcount; } else { c_g2(&kg2,f); if (kg2>=g2) ++pcount; } break; case FIX_N: simul(total,n,sample2,cum_c); simul(total,m,sample1,cum_r); taulukoi(sample1,sample2,f); if (test==PROB) { c_nprob(&kprob,f); if (kprob>=prob) { ++pcount; if (x2_file) { c_chi2(&kchi2,f); fprintf(tied,"%g\n",kchi2); } } } else if (test==X2) { c_chi2(&kchi2,f); if (kchi2>=chi2) ++pcount; } else { c_g2(&kg2,f); if (kg2>=g2) ++pcount; } break; case FIX_F: i=f_simul(); if (i<0) return(1); if (test==PROB) { i=c_fprob(&kprob,f); if (i<0) return(1); if (kprob>=prob) { ++pcount; if (x2_file) { c_chi2(&kchi2,f); fprintf(tied,"%g\n",kchi2); } } } else if (test==X2) { c_chi2(&kchi2,f); if (kchi2>=chi2) ++pcount; } else { c_g2(&kg2,f); if (kg2>=g2) ++pcount; } break; } if (dcount>=dn) { tab_disp(); if (count>=maxcount) break; if (sur_kbhit()) { sur_getch(); break; } dcount=0; // 21.10.2010 } } if (x2_file) muste_fclose(tied); return(1); }