int main() { int i,j,k,l,test,t=1; freopen("in.txt","r",stdin); scanf("%d",&test); while(test--) { scanf("%d %d %d %d",&n,&r,&p,&q); ii two,five; two=cal(n,2); two-=cal(r,2); two-=cal(n-r,2); five=cal(n,5); five-=cal(r,5); five-=cal(n-r,5); cal1(p); two+=(a[0]*q); five+=(a[1]*q); printf("Case %d: %lld\n",t++,mini(two,five)); } return 0; }
int main(){ int i,j,k,l,test,t=1,n; //freopen("in.txt","r",stdin); scanf("%d",&test); while(test--){ scanf("%d %d",&n,&k); double ans=cal1(n,k); double v=1000; if(ans<v) ans=ans*v; ii ans1=ans; while(ans1>=1000) ans1/=10; printf("Case %d: %03lld",t++,ans1); printf(" %03lld\n",big_mod(n,k,1000)); } return 0; }
int main(int argc, const char * argv[]) { int ff; int r1, r2; freopen("/Volumes/code/code/acm/hdoj/hdu5120/hdu5120/i", "r", stdin); freopen("/Volumes/code/code/acm/hdoj/hdu5120/hdu5120/o", "w", stdout); scanf("%d", &ff); for (int tt = 1; tt <= ff; tt++) { scanf("%d %d", &r1, &r2); scanf("%d %d", &x1, &yy1); scanf("%d %d", &x2, &y2); if (x1 == x2 && yy1 == y2) { printf("Case #%d: %0.6lf\n", tt, PI * r2 * r2 - PI * r1 * r1); continue; } double sum = cal1(r1, r1) - cal1(r1, r2) - cal1(r2, r1) + cal1(r2, r2); printf("Case #%d: %0.6lf\n", tt, sum); } }
void triple() { int i; double mid1, mid2, left, right, t1, t2; left = 0, right = dis(A, B); for (i = 1; i <= 100; i++) { mid1 = (left * 2 + right) / 3; mid2 = (left + 2 * right) / 3; t1 = cal1(mid1); t2 = cal1(mid2); if (t1 > t2) { left = mid1; } else { right = mid2; } } printf("%.2lf\n", cal1(left)); }
int main() { int i,k,f,g,l; scanf("%d",&test); for(i=0;i<test;i++) { style=i; out[i]=10000; scanf("%d %d",&m,&n); for(j=0;j<m;j++) scanf("%s",inp[j]); for(j=0;j<m;j++) { for(k=0;k<n;k++) { sub[j][k]=10000; if(inp[j][k]=='C') choc++; else if(inp[j][k]=='T') { sor[0]=j; sor[1]=k; } else if(inp[j][k]=='W') { tar[0]=j; tar[1]=k; } } } f=sor[0]; g=sor[1]; h=tar[0]; j=tar[1]; printf("%d\n",choc); chocSub=choc; chocBak=choc; sub[f][g]=0; cal2(f,g,0); choc=chocBak; sub[f][g]=0; cal1(f,g,0); choc=chocBak; sub[f][g]=0; cal3(f,g,0); choc=chocBak; sub[f][g]=0; cal4(f,g,0); printf("%d %d\n",sub[h][j],out[i]); for(j=0;j<m;j++) { for(k=0;k<n;k++) { printf("%d\t",sub[j][k]); sub[j][k]=10000; } printf("\n"); } choc=0; } return 0; }
double cal1(ii b,ii p){ if(p==1) return b; if(p==0) return 1; double v=100000000,bd=b; double ret1=cal1(b,p/2); while(ret1>v) ret1/=v; ret1*=ret1; while(ret1>v) ret1/=v; if(p%2) ret1*=bd; while(ret1>v) ret1/=v; return ret1; }
void cal1(int f,int g,int side) { int i,k,bak; if(sub[f][g]<10000) bak=sub[f][g]; else bak=-1; if(chocSub!=choc) { chocSub=choc; for(i=0;i<m;i++) for(k=0;k<n;k++) if(i!=f || k!=g) sub[i][k]=10000; } printf("One %d %d %d %c %d\n",f,g,sub[f][g],inp[f][g],choc); if(inp[f+1][g]!='#' && f+1<m) { if(inp[f+1][g]=='C') { if(sub[f+1][g]==10000 && choc>0) choc--; sub[f+1][g]=sub[f][g]+1; if(chocSub!=choc) { cal1(f+1,g,1); if(bak>0) sub[f][g]=bak; cal2(f+1,g,1); if(bak>0) sub[f][g]=bak; cal3(f+1,g,1); if(bak>0) sub[f][g]=bak; cal4(f+1,g,1); } else { if(side==0) { cal1(f+1,g,1); if(bak>0) sub[f][g]=bak; cal2(f+1,g,1); if(bak>0) sub[f][g]=bak; cal3(f+1,g,1); if(bak>0) sub[f][g]=bak; cal4(f+1,g,1);} else if(side==1) { cal2(f+1,g,1); if(bak>0) sub[f][g]=bak; cal3(f+1,g,1); if(bak>0) sub[f][g]=bak; cal1(f+1,g,1); } else if(side==4) { cal2(f+1,g,1); if(bak>0) sub[f][g]=bak; cal3(f+1,g,1); if(bak>0) sub[f][g]=bak; cal4(f+1,g,1); } } } else if(inp[f+1][g]=='W') { if(choc==0 && sub[f+1][g]>sub[f][g]+1) { sub[f+1][g]=sub[f][g]+1; } else if(choc!=0) { sub[f+1][g]=sub[f][g]+1; cal1(f+1,g,1); if(bak>0) sub[f][g]=bak; cal2(f+1,g,1); if(bak>0) sub[f][g]=bak; cal3(f+1,g,1); if(bak>0) sub[f][g]=bak; cal4(f+1,g,1); } } else if(inp[f+1][g]=='.' && (sub[h][j]==10000 || choc!=0)) { sub[f+1][g]=sub[f][g]+1; cal1(f+1,g,1); if(bak>0) sub[f][g]=bak; cal2(f+1,g,1); if(bak>0) sub[f][g]=bak; cal3(f+1,g,1); if(bak>0) sub[f][g]=bak; cal4(f+1,g,1); } else if(inp[f+1][g]=='T') { sub[f+1][g]=sub[f][g]+1; cal1(f+1,g,1); if(bak>0) sub[f][g]=bak; cal2(f+1,g,1); if(bak>0) sub[f][g]=bak; cal3(f+1,g,1); if(bak>0) sub[f][g]=bak; cal4(f+1,g,1); } } if(out[style]>sub[h][j] && choc==0) out[style]=sub[h][j]; }
int calculate(int i, int door) { if (door == 1)return cal1(i); else if (door == 2)return cal2(i); }
int Calibration::read(QString filename) { std::ifstream fichier((char*)filename.toStdString().c_str(), std::ios::in); if (!fichier) { qWarning() << "Cannot read calibration file " << filename; return 0; } clear(); std::string ligne; // déclaration d'une chaîne qui contiendra la ligne lue unsigned int etape_calcul = 0; while(std::getline(fichier,ligne)) // tant que l'on arrive pas a la fin du fichier { // take ending off the line ligne.erase(ligne.find_last_not_of(" \n\r\t")+1); if(!ligne.empty()) { // pivot + focale + axis + ccd rotation if(ligne.size() == 91) { etape_calcul = 1; } // sources if(ligne.size() == 70) { etape_calcul = 2; } if(!ligne.empty()) { switch(etape_calcul) { case 1: { char *buffer1 = strdup((char*)ligne.c_str()); QString id_BCAM = QString::fromStdString(strtok(buffer1," ")); QString tps_calib = QString::fromStdString(strtok( NULL, " " )); char *x_pivot = strtok( NULL, " " ); char *y_pivot = strtok( NULL, " " ); char *z_pivot = strtok( NULL, " " ); char *x_axis = strtok( NULL, " " ); char *y_axis = strtok( NULL, " " ); char *z_axis = strtok( NULL, " " ); char *dist_ccd_pivot = strtok( NULL, " " ); char *ccd_rotation = strtok( NULL, " " ); Point3d pv(atof(x_pivot), atof(y_pivot), atof(z_pivot)); Point3d ax(atof(x_axis), atof(y_axis),atof(z_axis)); float focale = atof(dist_ccd_pivot); float angle_rotation = atof(ccd_rotation); Calib1 cal1(id_BCAM, tps_calib, pv, ax, focale, angle_rotation); add(cal1); } break; case 2: { char *buffer2 = strdup((char*)ligne.c_str()); QString id_BCAM_2 = QString::fromStdString(strtok(buffer2," ")); QString tps_calib_2 = QString::fromStdString(strtok( NULL, " " )); char *x1_flash = strtok( NULL, " " ); char *y1_flash = strtok( NULL, " " ); char *x2_flash = strtok( NULL, " " ); char *y2_flash = strtok( NULL, " " ); char *z_flash = strtok( NULL, " " ); Point3d spt1(atof(x1_flash), atof(y1_flash), atof(z_flash)); Point3d spt2(atof(x2_flash), atof(y2_flash), atof(z_flash)); Calib2 cal2(id_BCAM_2, spt1, spt2); add(cal2); } break; } } } } //affichage du contenu de la base de donnees qui contient le fichier de calibration /*for(int i=0; i<base_donnees.Get_liste_calib1().size(); i++) { base_donnees.Get_liste_calib1().at(i).Affiche(); } for(int j=0; j<base_donnees.Get_liste_calib2().size(); j++) { base_donnees.Get_liste_calib2().at(j).Affiche(); }*/ fichier.close(); this->filename = filename; return 1; }