int main() { int n,p1,p2; siv(); while(scanf("%d",&n) && n) { int mid = (int)n/2; p1 = 2; while(p1<=mid) { if(status[p1]==0) { p2 = n - p1; if(status[p2]==0) break; else { p1++; } } else p1++; } if((p1+p2)==n) printf("%d = %d + %d\n",n,p1,p2); else printf("Goldbach's conjecture is wrong.\n"); p2 = 0; } return 0; }
void howmany() { siv(); int i,j,mod; int n = 1000000; digit[1] = 0; for(i=2; i<=22; i++) { digit[i] = digit[i-1]; if(status[i]==0) { printf("%d %d\n",i,i); digit[i]++; } else if(status[i]!=0) { mod = addfactor(i); if(status[mod]==0) printf("%d %d\n",i,mod); digit[i]++; } mod = 0; } }
/* 1.6 ~ToMListExpr~ converts this MFaces-object to the RList representation of an moving region suitable for import into a dbms. It takes care of creating the correct intervals (evaporation, main and/or condensation), and the borderregions. */ RList MFaces::ToMListExpr(Interval iv) { RList mreg; // Determine if we need a start- or endregion. This is exactly the case when // one of the contained MFace-objects of this MFaces-object needs it. bool needStartRegion = false, needEndRegion = false; for (unsigned int i = 0; i < faces.size(); i++) { needStartRegion = needStartRegion || faces[i].needStartRegion; needEndRegion = needEndRegion || faces[i].needEndRegion; } // one-third of the whole interval is used for the evaporisation and/or // condensation-phase double onethird = (iv.end - iv.start) / 3; // Calculate the intervals Interval evaporIv, condensIv; Interval startRegIv, endRegIv; Interval mainIv; mainIv = iv; mainIv.lc = mainIv.rc = true; if (needSEvap) { // Create the evaporation interval // the left side of the evaporation interval is always open, since we // need a borderregion there evaporIv.lc = false; evaporIv.start = mainIv.start; mainIv.start = mainIv.start + onethird; evaporIv.end = mainIv.start; evaporIv.rc = false; } if (needDEvap) { // Create the condensation interval // the right side of the condensation interval is always open, since we // need a borderregion there condensIv.rc = false; condensIv.end = mainIv.end; mainIv.end = mainIv.end - onethird; condensIv.start = mainIv.end; condensIv.lc = false; } if (needStartRegion) { // Create the start-region interval startRegIv.lc = true; startRegIv.start = mainIv.start; mainIv.start = mainIv.start + MOMENTMS; startRegIv.end = mainIv.start; startRegIv.rc = true; mainIv.lc = false; } if (needEndRegion) { // Create the end-region interval endRegIv.rc = true; endRegIv.end = mainIv.end; mainIv.end = mainIv.end - MOMENTMS; endRegIv.start = mainIv.end; endRegIv.lc = true; mainIv.rc = false; } if (needSEvap) { // We need to perform an evaporations-phase Interval siv(evaporIv.start, evaporIv.start, true, true); MFaces s = Face::CreateMFaces(sregs); mreg.append(s.ToListExpr(siv, 0, 1)); MFaces fs; // Reconstruct the borderfaces at the start of the main interpolation .. vector<Face> borderfaces = CreateBorderFaces(true); // and interpolate them with the original sourceregion with // the evaporation-mode-flag set. fs = interpolate(sregs, &borderfaces, 0, true, ""); mreg.append(fs.ToListExpr(evaporIv, 0, 1)); } if (needStartRegion) { // Create the borderregion at the begin of the main interpolation // interval here and add it to the list. mreg.append(CreateBorderMFaces(true).ToListExpr(startRegIv, 0, 1)); } // Add the main-interpolation mreg.append(ToListExpr(mainIv, 0, 1)); if (needEndRegion) { // Create the borderregion at the end of the main interpolation // interval here and add it to the list. mreg.append(CreateBorderMFaces(false).ToListExpr(endRegIv, 0, 1)); } if (needDEvap) { // A condensation-phase is needed MFaces fs; // Reconstruct the borderfaces at the end of the main interpolation .. vector<Face> borderdregs = CreateBorderFaces(false); // and interpolate them with the original destinationregion with // the evaporation-mode-flag set. fs = interpolate(&borderdregs, dregs, 0, true, ""); mreg.append(fs.ToListExpr(condensIv, 0, 1)); Interval eiv(condensIv.end, condensIv.end, true, true); MFaces s = Face::CreateMFaces(dregs); mreg.append(s.ToListExpr(eiv, 0, 1)); } return mreg; }