main() { char x[200], y[20]; /*freopen("in1.txt", "rt", stdin); freopen("out1.txt", "w+t", stdout);*/ while(scanf("%s", x) == 1) { BigNumber s1, s2, Ans, A; sprintf(y, "%d", 1); s1 = Change(x), s2 = Change(y); A = s1; sprintf(y, "%d", 0); Ans = Change(y); int a, t = 0; for(a = 1; a < 300; a += 2, t = 1-t) { if(t == 0) Ans = addit(Ans, divis(s1, s2)); else Ans = minus(Ans, divis(s1, s2)); /*Print(s1); puts(""); Print(s2); puts("");*/ s1 = multi(A, multi(s1, A)); sprintf(y, "%d", (a+1)*(a+2)); s2 = multi(s2, Change(y)); } Print(Ans); puts(""); } return 0; }/*
int main() { void multi(int *,int *,int),plus(int *,int *,int *); int i,j,n,m; int a[100]; scanf("%d%d",&n,&m); if (n<m) printf("0\n"); else { memset(f,0,sizeof(f)); for (i=1;i<=n;i++) { f[i][1][0]=1; f[i][1][1]=1; } for (i=2;i<=n;i++) for (j=2;j<=m;j++) { memset(a,0,sizeof(a)); multi(a,f[i-1][j],j); plus(f[i][j],f[i-1][j-1],a); } for (i=1;i<=m;i++) multi(f[n][m],f[n][m],i); for (i=f[n][m][0];i>=1;i--) printf("%d",f[n][m][i]); printf("\n"); } system("pause"); return(0); }
bool instPointInstance::installInst() { #if defined(cap_relocation) // This is harmless to call if there isn't a relocation in-flight func()->relocationInstall(); // the original relocation may force others; install them too for(unsigned i=0; i < force_reloc.size(); i++) { force_reloc[i]->relocationInstall(); } #endif if (!multi()) { // Alternative: keep a set of sequence #s for generated/ // installed/linked. We tried to generate and failed (prolly // due to stepping on a relocated function), so fail here // but don't assert. return false; } // We now "install", that is copy the generated code into the // addr space. This doesn't link. if (multi()->installMultiTramp() != multiTramp::mtSuccess) { fprintf(stderr, "Instance failed to install multiTramp, ret false\n"); return false; } return true; }
bool instPointInstance::linkInst() { #if defined(cap_relocation) // This is ignored (for now), is handled in updateInstInstances... pdvector<codeRange *> overwrittenObjs; // This is harmless to call if there isn't a relocation in-flight func()->relocationLink(overwrittenObjs); for(unsigned i=0; i < force_reloc.size(); i++) { force_reloc[i]->relocationLink(overwrittenObjs); } #endif // Funny thing is, we might very well try to link a multiTramp // multiple times... // Ah, well. // See comment in installInst if (!multi()) return false; if (multi()->linkMultiTramp() != multiTramp::mtSuccess) { fprintf(stderr, "ipInst: linkMulti returned false for 0x%lx\n", addr()); return false; } return true; }
void Procrustes(float *Q, float *Qavg, int n, float *P, float *Pavg, float *TLM) { float Ht[9]; // H=P*Q' Ht=Q*P' (' means transpose in my notation) float Ut[9], V[9], I[9]; float T[3]; // 3x1 translation vector float R[9]; // 3x3 rotation matrix float S[3]; // 3x1 vector of singular values Pavg[0] = (float)removeVectorMean(P, n); Pavg[1] = (float)removeVectorMean(P+n, n); Pavg[2] = (float)removeVectorMean(P+2*n, n); Qavg[0] = (float)removeVectorMean(Q, n); Qavg[1] = (float)removeVectorMean(Q+n, n); Qavg[2] = (float)removeVectorMean(Q+2*n, n); mat_mat_trans(Q,3,n,P,3,Ht); svd(Ht, 3, 3, Ut, V, S); multi(V,3,3,Ut,3,3,R); // Eq. (13) Arun et al. 1987 // if(opt_v) printf("det(R) = %f\n", det3(R)); if( det3(R) < 0.0 ) { // if(opt_v) printf("Negative determinant (reflection) detected\n"); V[2] *= -1.0; V[5] *= -1.0; V[8] *= -1.0; multi(V,3,3,Ut,3,3,R); // Eq. (13) Arun et al. 1987 // if(opt_v) printf("Corrected det(R) = %f\n", det3(R)); } multi(R,3,3,Pavg,3,1,T); for(int i=0; i<3; i++) T[i] = Qavg[i]-T[i]; // Eq. (10) Arun et al. 1987 // if(opt_v) printMatrix(T,3,1,"Translation:",NULL); set_to_I(TLM,4); TLM[0] = R[0]; TLM[1] = R[1]; TLM[2] = R[2]; TLM[3] = T[0]; TLM[4] = R[3]; TLM[5] = R[4]; TLM[6] = R[5]; TLM[7] = T[1]; TLM[8] = R[6]; TLM[9] = R[7]; TLM[10] = R[8]; TLM[11] = T[2]; return; }
bool judge(Point &a, Point &b) { if(dis(a, b) <= ZERO) return false; for(int i = 1; i <= n; i++) { if(multi(a, line[i].a, b) * multi(a, line[i].b, b) > ZERO) return false; } return true; }
int intersect(Point s1,Point e1,Point s2,Point e2) { return max(s1.x,e1.x) >= min(s2.x,e2.x) && max(s2.x,e2.x) >= min(s1.x,e1.x) && max(s1.y,e1.y) >= min(s2.y,e2.y) && max(s2.y,e2.y) >= min(s1.y,e1.y) && multi(s2,e1,s1) * multi(e1,e2,s1) >= 0 && multi(s1,e2,s2) * multi(e2,e1,s2) >= 0; }
void dj(double val[],int col[],int rowp[],double f[],double ui[], double us[], double u[]) { int n = N; // Size of matrix // Jacobi Parameter double omega = 2.0/3.0; // Stoping Parameters double rm[n],rnorm=0.0,rnorm_min=1e-6; // Residual double em[n],enorm=0.0,enorm_min=0.0; // Error // double e1m[n],e1norm=0.0,e1norm_min=0.0; // um+1 - um = wD^-1(rm); int itr=0, itr_max = 10000; // No. of iterations performed int i=0; //char s2; multi(val,col,rowp,ui,rm); // rm = au - multiply A and ui for (i=0;i<n;i++){ rm[i]=f[i]-rm[i]; em[i]=us[i]-u[i]; // e1m[i]=(omega/val[0])*(rm[i]); u[i]=ui[i]; // Initilizing u, just in case for redundant u } rnorm = linfnorm(rm); enorm = linfnorm(em); // e1norm = linfnorm(e1m); // Computations involved in iterations while (itr<=itr_max && rnorm>=rnorm_min && enorm>=enorm_min){ // e1norm>=e1norm_min for(i=1;i<n-1;i++){ u[i] = u[i] + (omega/val[2])*rm[i]; // val[0] for aii } u[0] = u[0] + (omega)*rm[0]; u[n-1] = u[n-1] + (omega)*rm[n-1]; multi(val,col,rowp,u,rm); // rm = au - multiply a and u-new for (i=0;i<n;i++) { em[i]=us[i]-u[i]; rm[i]=f[i]-rm[i]; // e1m[i]=(omega/val[0])*(rm[i]); } rnorm = linfnorm(rm); enorm = linfnorm(em); // e1norm = linfnorm(e1m); itr++; } // printf("No. of Iteration: %d\n",itr-1); // printf("Residual rm: %lf\n",rnorm); // printf("Error em: %lf\n",enorm); // printf("Improvement in last iteration: %lf\n",e1norm); }
int64 pow(int x,int64 p,int64 q) { int64 multi(int64,int64,int64); if (!p) return(1); int64 ans=pow(x,p>>1,q); ans=multi(ans,ans,q); if (p&1) ans=multi(ans,x,q); return(ans%q); }
bool isPointInTriangle2(TPoint p, TTriangle t) { //判断点是否在三角形内,线段的拐向判断 //APB, BPC, CPA 的拐向都是相同的 double k1, k2, k3; k1 = multi(t.t[0], t.t[1], p); k2 = multi(t.t[1], t.t[2], p); k3 = multi(t.t[2], t.t[0], p); if(k1 * k2 * k3 != 0){ if(k1 * k2 < 0) return false; if(k1 * k3 < 0) return false; } return true; }
int main(int argc, char* argv[]) { int a, b, c; char operator; printf("Please enter a expression"); scanf("%d %c %d", &a, &operator, &b); switch (operator) { case '+': c = add(a, b); break; case '-': c = sub(a, b); break; case '*': c = multi(a, b); break; case '/': c = div(a, b); break; } printf("result is %d.\n", c); return 0; }
void Svwt_thierry(double *Rinput,double *Iinput,double *Oreal, double *Oimage,double *pa,int *pinputsize, int *pM) { int octave, voice, nbvoice, i, j, k, inputsize, M; double a; double *Ri2, *Ri1, *Ii1, *Ii, *Ri; M = *pM; a = *pa; inputsize = *pinputsize; if(!(Ri2 = (double *) R_alloc((size_t) inputsize, sizeof(double) ))) error("Memory allocation failed for Ri2 in cwt_morlet.c \n"); if(!(Ri1 = (double *) R_alloc((size_t) inputsize, sizeof(double) ))) error("Memory allocation failed for Ri1 in cwt_morlet.c \n"); if(!(Ii1 = (double *) R_alloc((size_t) inputsize, sizeof(double) ))) error("Memory allocation failed for Ii1 in cwt_morlet.c \n"); if(!(Ri = (double *) R_alloc((size_t) inputsize, sizeof(double) ))) error("Memory allocation failed for Ri in cwt_morlet.c \n"); if(!(Ii = (double *) R_alloc((size_t) inputsize, sizeof(double) ))) error("Memory allocation failed for Ii in cwt_morlet.c \n"); for(i = 0; i < inputsize; i++) { Ri[i] = (double)Rinput[i]; Ii[i] = (double)Iinput[i]; } double_fft(Ri1,Ii1,Ri,Ii,inputsize,-1); thierry_frequency(M,a,Ri2,inputsize); multi(Ri1,Ii1,Ri2,Oreal,Oimage,inputsize); double_fft(Oreal,Oimage,Oreal,Oimage,inputsize,2); }
bool isIntersected(TPoint s1, TPoint e1, TPoint s2, TPoint e2) { //判断线段是否相交 //1.快速排斥试验判断以两条线段为对角线的两个矩形是否相交 //2.跨立试验 if( (max(s1.x, e1.x) >= min(s2.x, e2.x)) && (max(s2.x, e2.x) >= min(s1.x, e1.x)) && (max(s1.y, e1.y) >= min(s2.y, e2.y)) && (max(s2.y, e2.y) >= min(s1.y, e1.y)) && (multi(s2, e1, s1) * multi(e1, e2, s1) >= 0) && (multi(s1, e2, s2) * multi(e2, e1, s2) >= 0) ) return true; return false; }
int main(void){ int kotae; int mode; puts("足し算(1)と引き算(2)掛け算(3)割り算(4)どの計算する?"); puts("()の中の数字を入力してね!"); scanf("%d", &mode); switch(mode){ case 1:kotae = plus(); break; case 2:kotae = minus(); break; case 3:kotae = multi(); break; case 4:kotae = div(); } printf("答えは%dです",kotae); scanf("%d", &kotae); return 0; }
int main() { int used[12], i, j, res, m, n; char te[12]; //while( scanf("%d%d\n", &m, &n)!=EOF ) // { scanf("%d%d\n", &m, &n); for(i=0; i<m; i++) scanf("%s",&geo[i]); for(i=0; i<m; i++) used[i] = 0; for(i=0; i<m; i++) for(j=i+1; j<m; j++) { if( in(i, j) ) used[j] = 1; if( in(j, i) ) used[i] = 1; } memset(trie, 0, sizeof(trie)); memset(str, 0, sizeof(str)); for(tr_n=ma_n=i=0; i<m; i++) if( !used[i] ) add( 0, geo[i] ); memset(matrix, 0, sizeof(matrix)); getmatrix(); multi(n); res = 0; for(i=0; i<=ma_n; i++) res=(res+tt[0][i])%MOD; printf("%d\n", res); //} return 0; }
int main() { int i,n,top; scanf("%d%d",&n,&l); for(i=0; i<n; i++) scanf("%lf%lf",&p[i].x,&p[i].y); for(i=1; i<n; i++) if(p[i].y<p[0].y||(p[i].y==p[0].y&&p[i].x<p[0].x)) { t=p[0]; p[0]=p[i]; p[i]=t; } qsort(p+1,n-1,sizeof(p[1]),cmp); for(i=0; i<=2; i++) stack[i]=i; top=2; for(i=3; i<n; i++) { while(multi(p[i], p[stack[top]], p[stack[top - 1]]) >= 0) top--; top++; stack[top] = i; } s=0; for(i=0; i<=top; i++) s=s+distance(p[stack[i]],p[stack[(i+1)%(top+1)]]); pi=acos(-1.0); s=2*pi*l+s; printf("%.0lf\n",s); return 0; }
int main(int argc, char* argv[]) { int number1, number2, result; char operator; printf("Please enter a expression"); scanf("%d %c %d", &number1, &operator, &number2); switch (operator) { case '+': result = add(number1, number2); break; case '-': result = sub(number1, number2); break; case '*': result = multi(number1, number2); break; case '/': result = div(number1, number2); break; } printf("result is %d.\n", result); return 0; }
Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); sum=0; //temp=0; connect(ui->b1PushButton,SIGNAL(clicked()),this,SLOT(b1clicked())); connect(ui->b2PushButton,SIGNAL(clicked()),this,SLOT(b2clicked())); connect(ui->b3PushButton,SIGNAL(clicked()),this,SLOT(b3clicked())); connect(ui->b4PushButton,SIGNAL(clicked()),this,SLOT(b4clicked())); connect(ui->b5PushButton,SIGNAL(clicked()),this,SLOT(b5clicked())); connect(ui->b6PushButton,SIGNAL(clicked()),this,SLOT(b6clicked())); connect(ui->b7PushButton,SIGNAL(clicked()),this,SLOT(b7clicked())); connect(ui->b8PushButton,SIGNAL(clicked()),this,SLOT(b8clicked())); connect(ui->b9PushButton,SIGNAL(clicked()),this,SLOT(b9clicked())); connect(ui->b0PushButton,SIGNAL(clicked()),this,SLOT(b0clicked())); connect(ui->b00pushButton,SIGNAL(clicked()),this,SLOT(b00clicked())); connect(ui->addpushButton,SIGNAL(clicked()),this,SLOT(add())); connect(ui->subpushButton,SIGNAL(clicked()),this,SLOT(sub())); connect(ui->multipushButton,SIGNAL(clicked()),this,SLOT(multi())); connect(ui->divpushButton,SIGNAL(clicked()),this,SLOT(div())); connect(ui->equesPushButton,SIGNAL(clicked()),this,SLOT(equls())); connect(ui->quitpushButton,SIGNAL(clicked()),this,SLOT(quit())); connect(ui->clearPushButton,SIGNAL(clicked()),this,SLOT(clear())); }
void main() { int i,n; strcpy(num[0],"0"); for(count=1; count<=1000; count++) { itoa(count); } strcpy(a[0],"1"); for(count=1; count<=1000; count++) { strcpy(a[count],num[count]); multi(a[count],a[count-1]); } sum_fac[0]=1; while(scanf("%d",&n)!=EOF) { printf("%ld",sum_fac[n]); printf("\n"); } }
int main(int argc, char *argv[]){ int result, i, sum; printf("Name of file : %s\n", argv[0]); if(argc < 3){ printf("error"); return 0; //exit(1); } if(*argv[1] == '+'){ add(argv); } else if(*argv[1] == '-'){ deduction(argv); } else if(*argv[1] == 'm'){ multi(argv); } else if(*argv[1] == '/'){ divi(argv); } else{ return 0; } return 0; }
int main() { int a = add(1,2); int b = multi(2,3); printf("%d %d \n",a,b); }
void OnOK(HWND hWnd) { winx::SaveFileDialog dlg( _T("TIFF files(*.tif;*.tiff)\0*.tif;*.tiff\0"), _T("*.tif")); if (IDOK != dlg.DoModal()) return; TCHAR szFrame[] = _T("Frame1"); USES_CONVERSION; CLSID clsid; Gdiplus::GetEncoderClsid(L"image/tiff", &clsid); Gdiplus::MultiFrameImageCreator multi(T2CW(dlg.lpstrFile), clsid); for (UINT i = 1; i < 10; ++i) { szFrame[5] = '0' + i; ::SetDlgItemText(hWnd, IDC_PROMPT, szFrame); HBITMAP hbm = winx::ScreenCapture(hWnd); { Gdiplus::Bitmap bitmap(hbm, NULL); WINX_ASSERT(bitmap.GetLastStatus() == Gdiplus::Ok); multi.Add(bitmap); } ::DeleteObject(hbm); } CloseDialog(hWnd); }
void grahamScan(int n) { //Graham扫描求凸包 int i, u; //将最左下的点调整到p[0]的位置 u = 0; for(i = 1;i <= n - 1;i++){ if((point[i].y < point[u].y) || (point[i].y == point[u].y && point[i].x < point[u].x)) u = i; } swap(point, 0, u); //将平p[1]到p[n - 1]按按极角排序,可采用快速排序 qsort(point + 1, n - 1, sizeof(point[0]), cmp); for(i = 0;i <= 2;i++) stack[i] = i; top = 2; for(i = 3;i <= n - 1;i++){ while(multi(point[i], point[stack[top]], point[stack[top - 1]]) > 0){ top--; if(top == 0)break; } top++; stack[top] = i; } }
int main(int argc, char* argv[]) { int a, b, c; char operator; printf("ssafsdfsadfasdfasdfsdfasd"); printf("연산자를 아무거나 입력해주세요.~~~~~~~ ssafsdfsadfasdfasdfsdfasd"); scanf("%d %c %d", &a, &operator, &b); switch (operator) { case '+': c = add(a, b); break; case '-': c = sub(a, b); break; case '*': c = multi(a, b); break; case '/': c = div(a, b); break; } printf("result is %d.\n", c); return 0; }
int main() { int num1; int num2; int result; char flag; printf("please input first number\n"); scanf("%d",&num1); printf("please input char\n"); scanf("%c",&flag); printf("please input second number\n"); scanf("%d",&num2); switch(flag){ case '+': result = sum(num1,num2); break; case '-': result = minus(num1,num2); break; case '*': result = multi(num1,num2); break; case '/': result = devide(num1,num2); break; default: break; } printf("result is : %d\n",result); return 0; }
void Svwt_morlet(double *Rinput,double *Iinput,double *Oreal, double *Oimage,double *pa,int *pinputsize, double *pcenterfrequency) { int i, inputsize; double centerfrequency, a; double *Ri2, *Ri1, *Ii1, *Ii, *Ri; centerfrequency = *pcenterfrequency; a = *pa; inputsize = *pinputsize; if(!(Ri2 = (double *) R_alloc(inputsize, sizeof(double) ))) Rf_error("Memory allocation failed for Ri2 in cwt_morlet.c \n"); if(!(Ri1 = (double *) R_alloc(inputsize, sizeof(double) ))) Rf_error("Memory allocation failed for Ri1 in cwt_morlet.c \n"); if(!(Ii1 = (double *) R_alloc(inputsize, sizeof(double) ))) Rf_error("Memory allocation failed for Ii1 in cwt_morlet.c \n"); if(!(Ri = (double *) R_alloc(inputsize, sizeof(double) ))) Rf_error("Memory allocation failed for Ri in cwt_morlet.c \n"); if(!(Ii = (double *) R_alloc(inputsize, sizeof(double) ))) Rf_error("Memory allocation failed for Ii in cwt_morlet.c \n"); for(i = 0; i < inputsize; i++) { Ri[i] = (double)Rinput[i]; Ii[i] = (double)Iinput[i]; } double_fft(Ri1,Ii1,Ri,Ii,inputsize,-1); morlet_frequency(centerfrequency,a,Ri2,inputsize); multi(Ri1,Ii1,Ri2,Oreal,Oimage,inputsize); double_fft(Oreal,Oimage,Oreal,Oimage,inputsize,1); }
void SFMatrix::multi(SFVec3f *vector) { float value[3]; vector->getValue(value); multi(value); vector->setValue(value); }
void meniu() {int x=1; while(x) {for(i=0;i<=4;i++) for(j=0;j<=4;j++) a[i][j]=-1; int p; printf("Pentru a juca impotriva calculatorului apasati 1,iar pentru a juca impotriva unui prieten apasati 2!\n"); scanf("%d",&p); if(p==1) {printf("Pentru a juca cu 'X' apasati tasta 1,iar pentru a juca cu 'O' apasati tasta 0!\n"); scanf("%d",&n); ok=1; repetare(); printf("Pentru un joc nou apasati tasta 1,pentru a iesi apasati tasta 0!\n"); scanf("%d",&x); } else {multi(); ok=1; repetare_multi(); printf("Pentru un joc nou apasati tasta 1,pentru a iesi apasati tasta 0!\n"); scanf("%d",&x); } } }
PUBLIC MprList *mprListRegistry(cchar *key) { HKEY top, h; wchar name[ME_MAX_PATH]; MprList *list; int index, size; assert(key && *key); /* Get the registry hive */ if ((key = getHive(key, &top)) == 0) { return 0; } if (RegOpenKeyEx(top, wide(key), 0, KEY_READ, &h) != ERROR_SUCCESS) { return 0; } list = mprCreateList(0, 0); index = 0; while (1) { size = sizeof(name) / sizeof(wchar); if (RegEnumValue(h, index, name, &size, 0, NULL, NULL, NULL) != ERROR_SUCCESS) { break; } mprAddItem(list, sclone(multi(name))); index++; } RegCloseKey(h); return list; }
void Rotate(const Point_3 &s, double r) { double l=s.Length(); double x=s.x/l,y=s.y/l,z=s.z/l; double SinA=sin(r),CosA=cos(r); double p[4][4]={CosA + (1 - CosA) * x * x, (1 - CosA) * x * y - SinA * z, (1 - CosA) * x * z + SinA * y, 0,(1 - CosA) * y * x + SinA * z, CosA + (1 - CosA) * y * y, (1 - CosA) * y * z - SinA * x, 0, (1 - CosA) * z * x - SinA * y, (1 - CosA) * z * y + SinA * x, CosA + (1 - CosA) * z * z, 0, 0, 0, 0, 1}; multi(a,p); }