void CFmBall::CheckGoalArea() { if(abs(m_pPos->GetX()) > abs(INT_TO_FIXED(GOALPOST_X*BACK_X/1000))) { m_pPos->SetX(INT_TO_FIXED(GOALPOST_X*BACK_X/1000)*FmSign(m_pPos->GetX())); m_nAngle = Mod(360-m_nAngle, 360); m_nSpeedZ = m_nSpeedZ/6; m_nSpeed = m_nSpeed/6; //if(m_pPos->GetZ() < INT_TO_FIXED(20)) // m_pRefPlayMgr->m_pGoalPost[m_pPos->GetX()>0?1:0][2]->GetAniObject()->InitMotion(6, false); //else // m_pRefPlayMgr->m_pGoalPost[m_pPos->GetX()>0?1:0][2]->GetAniObject()->InitMotion(5, false); //GET_APP()->PlaySound(SOUND_KIND_GOALWEB, false); } if (abs(m_pPos->GetY()) > abs(INT_TO_FIXED(GOALPOST_Y*BACK_Y/1000))) { m_pPos->SetY(INT_TO_FIXED(GOALPOST_Y*BACK_Y/1000)*FmSign(m_pPos->GetY())); m_nAngle = Mod(180-m_nAngle, 360); m_nSpeedZ = m_nSpeedZ / 6; m_nSpeed = m_nSpeed / 3; //if(m_pPos->GetY() > 0) // m_pRefPlayMgr->m_pGoalPost[m_pPos->GetX()>0?1:0][0]->GetAniObject()->InitMotion(4, false); } if (m_pPos->GetZ() > INT_TO_FIXED(GOALPOST_Z)) { m_pPos->SetZ(INT_TO_FIXED(GOALPOST_Z)); m_nSpeedZ = m_nSpeedZ / 6; m_nSpeed = m_nSpeed / 6; if (m_nSpeedZ > 0) m_nSpeedZ *= -1; //m_pRefPlayMgr->m_pGoalPost[m_pPos->GetX()>0?1:0][0]->GetAniObject()->InitMotion(3, false); } }
void Instance::InsertMod(size_t index, const wxFileName &source) { wxFileName dest(Path::Combine(GetInstModsDir().GetFullPath(), source.GetFullName())); if (!source.SameAs(dest)) { wxCopyFile(source.GetFullPath(), dest.GetFullPath()); } dest.MakeRelativeTo(); SetNeedsRebuild(); int oldIndex = Find(modList.begin(), modList.end(), [&dest] (Mod mod) -> bool { return mod.GetFileName().SameAs(dest); }); if (oldIndex != -1) { modList.erase(modList.begin() + oldIndex); } if (index >= modList.size()) modList.push_back(Mod(dest)); else modList.insert(modList.begin() + index, Mod(dest)); SaveModList(); }
bool ModList::update() { if (!isValid()) return false; QList<Mod> newMods; m_dir.refresh(); auto folderContents = m_dir.entryInfoList(); bool orderWasInvalid = false; // first, process the ordered items (if any) int currentOrderIndex = 0; QStringList listOrder = readListFile(); for(auto item: listOrder) { QFileInfo info (m_dir.filePath(item)); int idx = folderContents.indexOf(info); // if the file from the index file exists if(idx != -1) { // remove from the actual folder contents list folderContents.takeAt(idx); // append the new mod newMods.append(Mod(info)); } else { orderWasInvalid = true; } } for(auto entry: folderContents) { newMods.append(Mod(entry)); } if(mods.size() != newMods.size()) { orderWasInvalid = true; } else for(int i = 0; i < mods.size(); i++) { if(!mods[i].strongCompare(newMods[i])) { orderWasInvalid = true; break; } } beginResetModel(); mods.swap(newMods); endResetModel(); if(orderWasInvalid) { saveListFile(); emit changed(); } return true; }
/* * Must guarantee c+c DO NOT OVERFLOW!!!(both a, b, c are INTEGERS) * $a or $b may be negative, however $c must be positive */ template<class T> T PowMod( T a, T b, T c) { T r=Mod((T)1,c); a=Mod(a,c); while(b != 0) { if(b & 1) r=MulMod(r, a, c); a = MulMod( a, a, c); b >>= 1; } return r; }
void multiply(L F[2][2], L M[2][2]) { L x = F[0][0]*M[0][0] + F[0][1]*M[1][0]; L y = F[0][0]*M[0][1] + F[0][1]*M[1][1]; L z = F[1][0]*M[0][0] + F[1][1]*M[1][0]; L w = F[1][0]*M[0][1] + F[1][1]*M[1][1]; F[0][0] = Mod(x); F[0][1] = Mod(y); F[1][0] = Mod(z); F[1][1] = Mod(w); }
wxDateTime RoundDateToSpan(wxDateTime date, wxDateSpan span) { wxDateTime::wxDateTime_t day = date.GetDay(); int month = MonthNum(date.GetMonth()); wxDateTime::wxDateTime_t year = date.GetYear(); wxDateTime::wxDateTime_t modDays = Mod(day - 1, span.GetTotalDays()); wxDateTime::wxDateTime_t modMonths = Mod(month - 1, span.GetMonths()); wxDateTime::wxDateTime_t modYears = Mod(year, span.GetYears()); return wxDateTime(day - modDays, MonthFromNum(month - modMonths), year - modYears); }
/* function to calculate the potency (a^n % q) */ Mod Mod::pot(unsigned int n){ if(n == 0){ return Mod(1); }else{ if(n == 1){ return Mod(get_a()); } if(n % 2 == 0){ return pot(n/2) * pot(n/2); } if(n % 2 == 1){ return pot(n-1) * Mod(get_a()); } } }
//debug single parquetShader parts extern "C" void test_parquetShader(DataStruct* data) { float m = data->f; //should be 1 float l = m -10; float r = m +10; data->fa[0] = Mod(l,r); data->fa[1] = Mod(r,l); data->fa[2] = Mod(r,m); data->fa[3] = Step(l,r); data->fa[4] = Step(r,l); data->fa[5] = SmoothStep(l,r,m); data->fa[6] = SmoothStep(l,r,100*m); data->fa[7] = SmoothStep(l,r,-200*m); data->fa[8] = Mix(l,r,m); }
BigData BigData:: operator%(const BigData& bigdata) { if (bigdata._strData[1] == '0') { cout << "除数为 0 或对0求模" << endl; assert(0); } if (_strData[1] == 0) return INT64(0); if ((IsINT64OverFlow()) && bigdata.IsINT64OverFlow()) { return _value % bigdata._value; } if (_strData.size() < bigdata._strData.size()) { return BigData(_strData.c_str()); } else if (_strData.size() == bigdata._strData.size()) { if (strcmp(_strData.c_str() + 1, bigdata._strData.c_str() + 1) < 0) return INT64(0); if (strcmp(_strData.c_str() + 1, bigdata._strData.c_str() + 1) == 0) { return INT64(0); } } return BigData(Mod(_strData, bigdata._strData).c_str()); }
void CFmBall::CheckUpperFence() //위쪽 펜스 비교 { /* if (m_pPos->GetY() < -INT_TO_FIXED(BACK_Y+UPPER_FENCE_DIS) && m_pPos->GetY() > -INT_TO_FIXED(BACK_Y+UPPER_FENCE_DIS+17)) //펜스 넘어감 { if (m_pPos->GetZ() < INT_TO_FIXED(17)) //펜스 높이에 걸림 { m_pPos->SetY(-INT_TO_FIXED(BACK_Y+UPPER_FENCE_DIS)); m_nAngle = Mod(180-m_nAngle, 360); m_nSpeed = m_nSpeed / 4; m_nSpeedZ = m_nSpeedZ / 4; } } else if (m_pPos->GetY() < -INT_TO_FIXED(BACK_Y+UPPER_FENCE_DIS+17) && m_pPos->GetY() > -INT_TO_FIXED(BACK_Y+UPPER_FENCE_DIS+17+30)) { if (m_pPos->GetZ() < 0) //펜스 높이에 걸림 { m_pPos->SetY(-INT_TO_FIXED(BACK_Y+UPPER_FENCE_DIS+17)); m_nAngle = Mod(180-m_nAngle, 360); m_nSpeed = m_nSpeed / 4; m_nSpeedZ = m_nSpeedZ / 4; } } else if (m_pPos->GetY() < -INT_TO_FIXED(BACK_Y+UPPER_FENCE_DIS+17+30) && m_pPos->GetY() > -INT_TO_FIXED(BACK_Y+UPPER_FENCE_DIS+17+30+37)) { if (m_pPos->GetZ() < INT_TO_FIXED(37)) //펜스 높이에 걸림 { m_pPos->SetY(-INT_TO_FIXED(BACK_Y+UPPER_FENCE_DIS+17+30)); m_nAngle = Mod(180-m_nAngle, 360); m_nSpeed = m_nSpeed / 4; m_nSpeedZ = m_nSpeedZ / 4; } } if (abs(m_pPos->GetX()) > INT_TO_FIXED(SIDE_FENCE_DIS_X*BACK_X/1000) && abs(m_pPos->GetX()) < INT_TO_FIXED(SIDE_FENCE_DIS_X*BACK_X/1000 + 17)) //펜스 넘어감 { if (m_pPos->GetZ() < INT_TO_FIXED(17)) //펜스 높이에 걸림 { if(m_pPos->GetX() > 0) { m_pPos->SetX(INT_TO_FIXED(SIDE_FENCE_DIS_X*BACK_X/1000)); } else { m_pPos->SetX(-INT_TO_FIXED(SIDE_FENCE_DIS_X*BACK_X/1000)); } m_nAngle = Mod(360-m_nAngle, 360); m_nSpeed = m_nSpeed / 4; m_nSpeedZ = m_nSpeedZ / 4; } } else { if (abs(m_pPos->GetX()) > INT_TO_FIXED(BACK_X+500)) //펜스 넘어감 { m_nAngle = Mod(360-m_nAngle, 360); m_nSpeed = m_nSpeed / 6; m_nSpeedZ = m_nSpeedZ / 6; } }*/ if (abs(m_pPos->GetY()) > INT_TO_FIXED(BACK_Y))//+500)) //펜스 넘어감 { m_pPos->SetY(FmSign(m_pPos->GetY())*INT_TO_FIXED(BACK_Y)); m_nAngle = Mod(180-m_nAngle, 360); // m_nSpeed = m_nSpeed / 6; // m_nSpeedZ = m_nSpeedZ / 6; } }
/*------------------------------------------------*/ int main(int argc,char **argv) { int i,j,k; int length,width,tailleCarre; float** MatriceImgR; float** MatriceImgI; float** MatriceImgM; // Generation d'une image carre blanc sur fond noir length = 128; width = 128; printf("Veuillez entrer la taille du carre: "); scanf("%d", &tailleCarre); MatriceImgR = squareImage(length, width, tailleCarre); // Sauvegarde de MatriceImgR sous forme d'image pgm SaveImagePgm(NAME_IMG_OUT,MatriceImgR,length,width); // Allocation memoire pour la FFT MatriceImgI=fmatrix_allocate_2d(length,width); MatriceImgM=fmatrix_allocate_2d(length,width); // Initialisation a zero de toutes les matrices for(i=0;i<length;i++) { for(j=0;j<width;j++) { MatriceImgI[i][j]=0.0; MatriceImgM[i][j]=0.0; } } // Decalage de l'image pour obtenir un spectre au centre shiftSpatial(MatriceImgR,length,width); // FFT FFTDD(MatriceImgR,MatriceImgI,length,width); // Module Mod(MatriceImgM,MatriceImgR,MatriceImgI,length,width); // Pour visu //RecalLog(MatriceImgM,length,width); Recal(MatriceImgM,length,width); Mult(MatriceImgM,20,length,width); // Sauvegarde de MatriceImgM sous forme d'image pgm SaveImagePgm(NAME_SPC_OUT,MatriceImgM,length,width); // Liberation memoire pour les matrices free_fmatrix_2d(MatriceImgR); free_fmatrix_2d(MatriceImgI); free_fmatrix_2d(MatriceImgM); // Retour sans probleme printf("\n C'est fini ... \n\n\n"); return 0; }
int main() { // printf("hello, world"); char result[BUFFER_SIZE]; char remainder[BUFFER_SIZE]; // please make sure the bit length is enough before calculate // especially when you do a large power operation // you can change it by define: BIG_INT_BIT_LEN // the default bit length for BigInt is 1024 // routine test puts(Add("2010", "4", result)); puts(Sub("0", "2014", result)); puts(Mul("2", "43", result)); puts(Div("86", "10", result, remainder)); puts(remainder); puts(Mod("-86", "10", result)); puts(PowMod("7", "80", "86", result)); // BigInt test puts(Sub("233333333333333333333333333333333333333333333333", "33", result)); puts(Mul("2333333333333333333333333333333", "2333333333333333333", result)); puts(Div("2333333333333333333333333333333", "2333333333333333332", result, remainder)); puts(remainder); puts(Pow("8", "86", result)); return 0; }
void Instance::LoadModList() { if (GetModListFile().FileExists()) { wxFileInputStream inputStream(GetModListFile().GetFullPath()); wxStringList modListFile = ReadAllLines(inputStream); for (wxStringList::iterator iter = modListFile.begin(); iter != modListFile.end(); iter++) { // Normalize the path to the instMods dir. wxFileName modFile(*iter); modFile.Normalize(wxPATH_NORM_ALL, GetInstModsDir().GetFullPath()); modFile.MakeRelativeTo(); if (!Any(modList.begin(), modList.end(), [&modFile] (Mod mod) -> bool { return mod.GetFileName().SameAs(wxFileName(modFile)); })) { //SetNeedsRebuild(); modList.push_back(Mod(modFile)); } } } for (size_t i = 0; i < modList.size(); i++) { if (!modList[i].GetFileName().FileExists()) { SetNeedsRebuild(); modList.erase(modList.begin() + i); i--; } } LoadModListFromDir(GetInstModsDir()); }
void aui_Tab::MouseLGrabInside( aui_MouseEvent *mouseData ) { if ( IsDisabled() ) return; if ( !GetWhichSeesMouse() || GetWhichSeesMouse() == this ) { SetWhichSeesMouse( this ); PlaySound( AUI_SOUNDBASE_SOUND_EXECUTE ); HideTipWindow(); SetMouseOwnership(); ReleaseMouseOwnership(); SetKeyboardFocus(); m_mouseCode = AUI_ERRCODE_HANDLEDEXCLUSIVE; if ( !HandleGameSpecificLeftClick( this ) ) if ( 0 < m_state && m_state < m_numStates - 1 ) SetState( Mod(m_state+1,m_numStates) ); else SetState( 1 ); m_attributes |= k_CONTROL_ATTRIBUTE_ACTIVE; m_draw |= m_drawMask & k_AUI_REGION_DRAWFLAG_MOUSELGRABINSIDE; } else MouseLGrabOutside( mouseData ); }
int main() { int B, P, M; while(scanf("%d %d %d", &B, &P, &M) == 3) { printf("%lld\n", Mod(B, P, M)); } return 0; }
void main(){ int a,b,t; printf("enter the a and b value:\n"); scanf("%d %d",&a,&b); Mod(a,b); printf("t=%d",t); }
void Negate() { T nim = -1 / Mod(); x *= nim; y *= nim; z *= nim; w *= -nim; }
void ex_gcd(int a, int b, int &x, int& y) { if (!b) { x = 1, y = 0; return; } ex_gcd(b, Mod(a, b), x, y); int t = x; x = y, y = t - a / b * y; }
bool CFmBall::Update(bool bTmp/* = false*/) { bool ret = false; //좌표이동 *m_pPos = *m_pPos + FmP3D(-sin(CC_DEGREES_TO_RADIANS(m_nAngle))*m_nSpeed, cos(CC_DEGREES_TO_RADIANS(m_nAngle))*m_nSpeed, m_nSpeedZ); if(!bTmp) ret = CheckGoalpost(); if(m_pPos->GetZ() <= 0) //땅에 닿았을때 처리 { if(m_nSpeedZ == 0) { if(m_nSpeed/20 > CON_SPEED_REG2) m_nSpeed -= m_nSpeed/20; //공 빠르면 많이 차감 else m_nSpeed -= CON_SPEED_REG2; //공기 저항 속도 } else { m_nSpeed = m_nSpeed * CON_SPEED_REG/1000 - CON_SPEED_REG2; } m_nSpeedZ = -m_nSpeedZ * CON_SPEEDZ_REG/1000 - CON_SPEEDZ_REG2; //Z축 속도 감소 if(m_nSpeedZ < INT_TO_FIXED(1)) m_nSpeedZ = 0; m_pPos->SetZ(0); m_nAngle = m_nAngle + m_nSpin/16; m_nSpin = m_nSpin * CON_SPIN_REG/1000; if(!bTmp) { if(m_nSpeedZ != 0) SetBoundPos(); else m_nBoundHH = -1; } } else { m_nSpeed = m_nSpeed * CON_SPEED_AIR_REG/1000; m_nSpeedZ -= CON_SPEEDZ_AIR_REG; int t = 10 + m_nSpeed / INT_TO_FIXED(30); m_nAngle = m_nAngle + m_nSpin*t/900; m_nSpin = m_nSpin * CON_SPIN_AIR_REG/1000; } m_nAngle = Mod(m_nAngle, 360); if(m_nSpeed < INT_TO_FIXED(1)) m_nSpeed = 0; if(m_nNotForceFlag > 0) m_nNotForceFlag--; if(m_nMissFlag > 0) m_nMissFlag--; return ret; }
inline int Gao(int a, int b, int c) { int t = gcd(abs(a), abs(b)); if (a < 0 || b < 0) t = -t; if (Mod(c, t) != 0) return 1521521521; int x = 0, y = 0; a /= t, b /= t, c /= t; ex_gcd(a, b, x, y); x *= c; while (x < 0) x += b; while (x > b) x -= b; return x; }
bool FrameLimiter::ShouldUpdate(float frametime) { t += frametime; if (t >= step) { t = Mod(t, step); return true; } return false; }
//////////////////////////// // REturn the modules sMoney sMoney::operator %(const int r) { sMoney Mod(*this); Mod.Copper%=r; Mod.Gold%=r; Mod.Silver%=r; Mod.Plat%=r; Mod.ReCalcBase(); return Mod; }
L luc(L n) { L s; if(n==0) return 2; else if(n==1) return 1; L F[2][2]={{1,1},{1,0}}; power(F,n); s=F[1][0]+2*F[1][1]; s=Mod(s); return s; }
L fib(L n) { L s; if(n==0) return 0; else if(n==1) return 1; L F[2][2]={{1,1},{1,0}}; power(F,n); s=F[1][0]; s=Mod(s); return s; }
int64_t HaltonSampler::GetIndexForSample(int64_t sampleNum) const { if (currentPixel != pixelForOffset) { // Compute Halton sample offset for _currentPixel_ offsetForCurrentPixel = 0; if (sampleStride > 1) { Point2i pm(Mod(currentPixel[0], kMaxResolution), Mod(currentPixel[1], kMaxResolution)); for (int i = 0; i < 2; ++i) { uint64_t dimOffset = (i == 0) ? InverseRadicalInverse<2>(pm[i], baseExponents[i]) : InverseRadicalInverse<3>(pm[i], baseExponents[i]); offsetForCurrentPixel += dimOffset * (sampleStride / baseScales[i]) * multInverse[i]; } offsetForCurrentPixel %= sampleStride; } pixelForOffset = currentPixel; } return offsetForCurrentPixel + sampleNum * sampleStride; }
int main() { scanf("%s%s%s%s%s%s%s%s", n, m, na, nb, nc, nd, ne, nf); nl = strlen(n), ml = strlen(m); a = Mod(na), b = Mod(nb), c = Mod(nc), d = Mod(nd), e = Mod(ne), f = Mod(nf); mata.a3 = matb.a3 = 1; mata.a2 = a, mata.a4 = b, mata.a6 = c; matb.a2 = d, matb.a4 = e, matb.a6 = f; for(int i = 0; i < nl; i++) n[i] -= '0'; for(int i = 0; i < ml; i++) m[i] -= '0'; n[nl - 1]--; for(int i = nl - 1; i >= 0 && n[i] < 0; i--) n[i] += 10, n[i - 1]--; m[ml - 1] -= 2; for(int i = ml - 1; i >= 0 && m[i] < 0; i--) m[i] += 10, m[i - 1]--; Matrix tmp = MatPow(mata, m, ml); Matrix sub = tmp; sub *= matb, sub *= matb; Matrix ans = MatPow(sub, n, nl); ans *= tmp; printf("%d", (int)((ans.a2 + ans.a4 + ans.a6) % mod)); return 0; }
static void FillRightOrientedTriangle (HDC hDc) { long y = points [LOW_POINT].y; long leftEdge = points [LOW_POINT].x; long rightEdge = points [LOW_POINT].x; long leftDx = longEdge->dx; long leftDy = longEdge->dy; long rightDx; long rightDy; long leftConst = Floor (longEdge->dx, longEdge->dy); long rightConst; long leftMod = Mod (longEdge->dx, longEdge->dy); long rightMod; long leftNumer = -1; long rightNumer = -1; rightConst = Floor (lowEdge->dx, lowEdge->dy); rightDx = lowEdge->dx; rightDy = lowEdge->dy; rightMod = Mod (rightDx, rightDy); while (lowEdge->dy--) { WriteRow (hDc, leftEdge, rightEdge, y++); leftEdge += leftConst + Floor (Mod (leftNumer, leftDy) + leftMod, leftDy); rightEdge += rightConst + Floor (Mod (rightNumer, rightDy) + rightMod, rightDy); leftNumer += leftDx; rightNumer += rightDx; } rightConst = Floor (topEdge->dx, topEdge->dy); rightDx = topEdge->dx; rightDy = topEdge->dy; rightMod = Mod (rightDx, rightDy); while (topEdge->dy--) { WriteRow (hDc, leftEdge, rightEdge, y++); leftEdge += leftConst + Floor (Mod (leftNumer, leftDy) + leftMod, leftDy); rightEdge += rightConst + Floor (Mod (rightNumer, rightDy) + rightMod, rightDy); leftNumer += leftDx; rightNumer += rightDx; } }
int main(){ int t; scanf("%d",&t); while(t--){ L n,N; //N=scanInt(); scanf("%lld",&N); if(N==0||N==1) {puts("0");continue;} n=N+5; //N=scanInt(); //printf("%ld\n",luc(N)); L ans=(Mod(Mod(n)*luc(n))-fib(n)); ans=(ans*400000003)%MOD; //ans=Mod(ans-2*fib(n-1)); //ans=Mod(ans-2*fib(n-2)); //ans=Mod(ans-3*fib(n-3)); ans=Mod(ans+2*fib(N)-4*fib(N+4)-fib(N+2)); printf("%ld\n",ans); //printf("%ld\n",Mod(Mod((Mod(n)*luc(n)-fib(n))/5)-2*fib(n-1)-2*fib(n-2)-Mod(3*fib(n-3)+2*fib(N)))); } return 0; }
Expression *ModExp::optimize(int result) { Expression *e; e1 = e1->optimize(result); e2 = e2->optimize(result); if (e1->isConst() == 1 && e2->isConst() == 1) { e = Mod(type, e1, e2); } else e = this; return e; }
template <class T> T AbstractEuclideanDomain<T>::Gcd(const Element &a, const Element &b) const { Element g[3]={b, a}; unsigned int i0=0, i1=1, i2=2; while (!Equal(g[i1], Zero())) { g[i2] = Mod(g[i0], g[i1]); unsigned int t = i0; i0 = i1; i1 = i2; i2 = t; } return g[i0]; }