unsigned long long euler2(int x, int y, int n){ if(x == n || y == n){ return 1; } else{ return euler2(x + 1, y, n) + euler2(x, y + 1, n); } }
void euler2(int v) { c[v]++; for (int u = 0; u < 26; u++) if (g[u][v]) { g[u][v]--; c[v]--; euler2(u); } }
/** * Funkce, ktera vraci jak daleko je reseni ODR od pozadovane hodnoty v pravem bode, * jako parametr bere derivaci hledane funkce v bode 0, jako data bere ukazatel na zadani * odr. */ double f_pro_newtona(double parametr, const void *data) { const struct odr2 *odr = (const struct odr2 *) data; int vysledek; vysledek = euler2(odr, parametr); if(vysledek != 0) { fprintf(stderr, "Chyba pri eulerovi.\n"); exit(1); } else { /* vratime vzdalenost reseni v pravem bode od pozadovane hodnoty: */ return odr->y[odr->N - 1] - odr->beta; } }
int _tmain(int argc, _TCHAR* argv[]) { float a = fatorial(4); printf("Fatorial: %f", a); float b = euler(); printf("\nEuler: %f", b); float c = euler2(2); printf("\nEuler 2: %f", c); float d = expo(4, 3); printf("\nExpo: %f", d); printf("\n\n"); return 0; }
int main() { int t; scanf("%d", &t) == 1; while (t--) { scanf("%d", &n) == 1; memset(g, 0, sizeof(g)); memset(c, 0, sizeof(c)); memset(s, '\0', sizeof(s)); int cnt = n; while (cnt--) { scanf("%s", s) == 1; g[s[0]-'a'][s[strlen(s)-1]-'a']++; } for (int i = 0; i < 26; i++) for (int j = 0; j < 26; j++) if (g[i][j]) { euler1(i); euler2(i); goto start; } start: bool iscon = true; for (int i = 0; i < 26; i++) for (int j = 0; j < 26; j++) if (g[i][j]) { iscon = false; goto end; } end: int dcnt = 0; for (int i = 0; i < 26; i++) if (c[i]) dcnt++; if (!iscon || dcnt > 2) { printf("The door cannot be opened.\n"); continue; } printf("Ordering is possible.\n"); // for (int i = 0; i < 26; i++) { // for (int j = 0; j < 26; j++) // printf("%d", g[i][j]); // printf("\n"); // } // printf("\n"); } return 0; }
TString MillePedeTrees::Gamma(const TString &tree, bool betaMpiPpi) const { TString euler1("TMath::ASin(Rot[6])"); if (!betaMpiPpi) euler1.Prepend("TMath::Pi() - "); TString euler2("TMath::ATan(-Rot[3]/Rot[0]) + (TMath::Pi() * (TMath::Cos("); euler2 += euler1; euler2 += ") * Rot[0] <= 0))"; TString result(Form("(TMath::Abs(Rot[6] - 1.0) >= 1.e-6) * (%s)", euler2.Data())); result += "+ (TMath::Abs(Rot[6] - 1.0) < 1.e-6) * (TMath::ATan(Rot[5]/Rot[4]))"; result.ReplaceAll("Rot[", tree + "Rot["); return result; /* if (TMath::Abs(Rot[6] - 1.0) > 1.e-6) { // If angle1 is not +-PI/2 if (flag == 0) // assuming -PI/2 < angle1 < PI/2 euler[1] = TMath::ASin(Rot[6]); // New beta sign convention else // assuming angle1 < -PI/2 or angle1 >PI/2 euler[1] = TMath::Pi() - TMath::ASin(Rot[6]); // New beta sign convention if (TMath::Cos(euler[1]) * Rot[8] > 0) euler[0] = TMath::ATan(-Rot[7]/Rot[8]); else euler[0] = TMath::ATan(-Rot[7]/Rot[8]) + TMath::Pi(); if (TMath::Cos(euler[1]) * Rot[0] > 0) euler[2] = TMath::ATan(-Rot[3]/Rot[0]); else euler[2] = TMath::ATan(-Rot[3]/Rot[0]) + TMath::Pi(); } else { // if angle1 == +-PI/2 euler[1] = TMath::PiOver2(); // chose positve Solution if(Rot[8] > 0) { euler[2] = TMath::ATan(Rot[5]/Rot[4]); euler[0] = 0; } } */ }
unsigned long long euler(int n){ return euler2(0, 0, n); }