main() { int t; long long int x,y,z; double a,b,c,d,b1,a1,a2; scanf("%d",&t); while(t--) { scanf("%lld%lld%lld",&x,&y,&z); a=1.0*(y+2*z); b=(x*z*1.0)/a; c=1.0*((y)/a)*z*z; b1=(b*b)+c; b1=sqrt(b1); a1=b+b1; a2=b-b1; if(a1>=0 && a1<=x) { if(a1-llrintl(a1)==0.00) printf("%lld\n",llrintl(a1)); else printf("Not this time.\n"); } else if(a2>=0 && a2<=x) { if(a2-llrintl(a2)==0.00) printf("%lld\n",llrintl(a2)); else printf("Not this time.\n"); } else printf("Not this time.\n"); } return 0; }
int main() { int t; // int t,n,diff,i; scanf("%d",&t); // long long int n3,n3n,sum,start,a,b,c,d,r1,r2; long long int a3,a3l,s,i,a,d,len; long double n,sq,diff; while(t--) { scanf("%lld",&a3); scanf("%lld",&a3l); scanf("%lld",&s); sq=sqrtl(((5.0*a3l+7.0*a3+2.0*s)*(5.0*a3l+7.0*a3+2.0*s))-(48.0*(a3l+a3)*s)); n=((5.0*a3l+7.0*a3+2.0*s)+sq)/(2.0*(a3l+a3)); len=llrintl(n); printf("%lld\n",len); diff=(a3l-a3)/(len-6.0); d=llrintl(diff); a=(a3-(2*d)); for(i=0;i<len;i++) { printf("%lld ",a+i*d); } printf("\n"); /* scanf("%lld%lld%lld",&n3,&n3n,&sum); a=(n3+n3n); b=(7*n3+5*n3n+(2*sum)); c=12*sum; d=(b*b)-(4*a*c); r1=floorl(abs((-b-sqrtl(d))/(2*a))); r2=ceill(abs((-b+sqrtl(d))/(2*a))); //printf("%lld and %lld\n",r1,r2); n=r1>r2?r1:r2; //n++; //diff=(sum-(n*n3))/(((n*(n-1))/2)-(2*n)); diff=(n3n-n3)/(n-6); //printf("%d-%d\n",n,diff); start=n3-(2*diff); printf("%d\n",n); for(i=0;i<n;i++) { printf("%lld ",start); start+=diff; } //printf("\n"); */ } return 0; }
void test_llrint() { static_assert((std::is_same<decltype(llrint((double)0)), long long>::value), ""); static_assert((std::is_same<decltype(llrintf(0)), long long>::value), ""); static_assert((std::is_same<decltype(llrintl(0)), long long>::value), ""); assert(llrint(1) == 1LL); }
int main(void) { #pragma STDC FENV_ACCESS ON long long yi; int e, i, err = 0; struct l_i *p; for (i = 0; i < sizeof t/sizeof *t; i++) { p = t + i; if (p->r < 0) continue; fesetround(p->r); feclearexcept(FE_ALL_EXCEPT); yi = llrintl(p->x); e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); if (!checkexcept(e, p->e, p->r)) { printf("%s:%d: bad fp exception: %s llrintl(%La)=%lld, want %s", p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e)); printf(" got %s\n", estr(e)); err++; } if (!(p->e&INVALID) && yi != p->i) { printf("%s:%d: %s llrintl(%La) want %lld got %lld\n", p->file, p->line, rstr(p->r), p->x, p->i, yi); err++; } } return !!err; }
TEST(math, lrint) { fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode. ASSERT_EQ(1235, lrint(1234.01)); ASSERT_EQ(1235, lrintf(1234.01f)); ASSERT_EQ(1235, lrintl(1234.01)); fesetround(FE_TOWARDZERO); // lrint/lrintf/lrintl obey the rounding mode. ASSERT_EQ(1234, lrint(1234.01)); ASSERT_EQ(1234, lrintf(1234.01f)); ASSERT_EQ(1234, lrintl(1234.01)); fesetround(FE_UPWARD); // llrint/llrintf/llrintl obey the rounding mode. ASSERT_EQ(1235L, llrint(1234.01)); ASSERT_EQ(1235L, llrintf(1234.01f)); ASSERT_EQ(1235L, llrintl(1234.01)); fesetround(FE_TOWARDZERO); // llrint/llrintf/llrintl obey the rounding mode. ASSERT_EQ(1234L, llrint(1234.01)); ASSERT_EQ(1234L, llrintf(1234.01f)); ASSERT_EQ(1234L, llrintl(1234.01)); }
void testl(long double x) { #ifdef HAVE_C99_RUNTIME if (sizeof(long) != sizeof(long long)) return; if (lroundl(x) != llroundl(x)) link_error(); if (lrintl(x) != llrintl(x)) link_error(); #endif }
int64 hpix_ring_num(const struct healpix* hpix, double z) { int64 nside=hpix->nside; // rounds double to nearest long long int int64 iring = llrintl( nside*(2.-1.5*z) ); // north cap if (z > M_TWOTHIRD) { iring = llrintl( nside* sqrt(3.*(1.-z)) ); if (iring == 0) { iring = 1; } } else if (z < -M_TWOTHIRD) { iring = llrintl( nside* sqrt(3.*(1.+z)) ); if (iring == 0) { iring = 1; } iring = 4*nside - iring; } return iring; }
TEST(math, lrint) { auto guard = make_scope_guard([]() { fesetenv(FE_DFL_ENV); }); fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode. ASSERT_EQ(1235, lrint(1234.01)); ASSERT_EQ(1235, lrintf(1234.01f)); ASSERT_EQ(1235, lrintl(1234.01L)); fesetround(FE_TOWARDZERO); // lrint/lrintf/lrintl obey the rounding mode. ASSERT_EQ(1234, lrint(1234.01)); ASSERT_EQ(1234, lrintf(1234.01f)); ASSERT_EQ(1234, lrintl(1234.01L)); fesetround(FE_UPWARD); // llrint/llrintf/llrintl obey the rounding mode. ASSERT_EQ(1235L, llrint(1234.01)); ASSERT_EQ(1235L, llrintf(1234.01f)); ASSERT_EQ(1235L, llrintl(1234.01L)); fesetround(FE_TOWARDZERO); // llrint/llrintf/llrintl obey the rounding mode. ASSERT_EQ(1234L, llrint(1234.01)); ASSERT_EQ(1234L, llrintf(1234.01f)); ASSERT_EQ(1234L, llrintl(1234.01L)); }
void testl(long double x) { #ifdef HAVE_C99_RUNTIME if (sizeof(long) != sizeof(long long)) return; if (__builtin_lceill(x) != __builtin_llceill(x)) link_error(); if (__builtin_lfloorl(x) != __builtin_llfloorl(x)) link_error(); if (lroundl(x) != llroundl(x)) link_error(); if (lrintl(x) != llrintl(x)) link_error(); #endif }
int main(int argc, char *argv[]) { long double x = 0.0; if (argv) x = llrintl((long double) argc); return 0; }
int64_t floatx80_to_int64( floatx80 a STATUS_PARAM) { return llrintl(a); }
void domathl (void) { #ifndef NO_LONG_DOUBLE long double f1; long double f2; int i1; f1 = acosl(0.0); fprintf( stdout, "acosl : %Lf\n", f1); f1 = acoshl(0.0); fprintf( stdout, "acoshl : %Lf\n", f1); f1 = asinl(1.0); fprintf( stdout, "asinl : %Lf\n", f1); f1 = asinhl(1.0); fprintf( stdout, "asinhl : %Lf\n", f1); f1 = atanl(M_PI_4); fprintf( stdout, "atanl : %Lf\n", f1); f1 = atan2l(2.3, 2.3); fprintf( stdout, "atan2l : %Lf\n", f1); f1 = atanhl(1.0); fprintf( stdout, "atanhl : %Lf\n", f1); f1 = cbrtl(27.0); fprintf( stdout, "cbrtl : %Lf\n", f1); f1 = ceill(3.5); fprintf( stdout, "ceill : %Lf\n", f1); f1 = copysignl(3.5, -2.5); fprintf( stdout, "copysignl : %Lf\n", f1); f1 = cosl(M_PI_2); fprintf( stdout, "cosl : %Lf\n", f1); f1 = coshl(M_PI_2); fprintf( stdout, "coshl : %Lf\n", f1); f1 = erfl(42.0); fprintf( stdout, "erfl : %Lf\n", f1); f1 = erfcl(42.0); fprintf( stdout, "erfcl : %Lf\n", f1); f1 = expl(0.42); fprintf( stdout, "expl : %Lf\n", f1); f1 = exp2l(0.42); fprintf( stdout, "exp2l : %Lf\n", f1); f1 = expm1l(0.00042); fprintf( stdout, "expm1l : %Lf\n", f1); f1 = fabsl(-1.123); fprintf( stdout, "fabsl : %Lf\n", f1); f1 = fdiml(1.123, 2.123); fprintf( stdout, "fdiml : %Lf\n", f1); f1 = floorl(0.5); fprintf( stdout, "floorl : %Lf\n", f1); f1 = floorl(-0.5); fprintf( stdout, "floorl : %Lf\n", f1); f1 = fmal(2.1, 2.2, 3.01); fprintf( stdout, "fmal : %Lf\n", f1); f1 = fmaxl(-0.42, 0.42); fprintf( stdout, "fmaxl : %Lf\n", f1); f1 = fminl(-0.42, 0.42); fprintf( stdout, "fminl : %Lf\n", f1); f1 = fmodl(42.0, 3.0); fprintf( stdout, "fmodl : %Lf\n", f1); /* no type-specific variant */ i1 = fpclassify(1.0); fprintf( stdout, "fpclassify : %d\n", i1); f1 = frexpl(42.0, &i1); fprintf( stdout, "frexpl : %Lf\n", f1); f1 = hypotl(42.0, 42.0); fprintf( stdout, "hypotl : %Lf\n", f1); i1 = ilogbl(42.0); fprintf( stdout, "ilogbl : %d\n", i1); /* no type-specific variant */ i1 = isfinite(3.0); fprintf( stdout, "isfinite : %d\n", i1); /* no type-specific variant */ i1 = isgreater(3.0, 3.1); fprintf( stdout, "isgreater : %d\n", i1); /* no type-specific variant */ i1 = isgreaterequal(3.0, 3.1); fprintf( stdout, "isgreaterequal : %d\n", i1); /* no type-specific variant */ i1 = isinf(3.0); fprintf( stdout, "isinf : %d\n", i1); /* no type-specific variant */ i1 = isless(3.0, 3.1); fprintf( stdout, "isless : %d\n", i1); /* no type-specific variant */ i1 = islessequal(3.0, 3.1); fprintf( stdout, "islessequal : %d\n", i1); /* no type-specific variant */ i1 = islessgreater(3.0, 3.1); fprintf( stdout, "islessgreater : %d\n", i1); /* no type-specific variant */ i1 = isnan(0.0); fprintf( stdout, "isnan : %d\n", i1); /* no type-specific variant */ i1 = isnormal(3.0); fprintf( stdout, "isnormal : %d\n", i1); /* no type-specific variant */ f1 = isunordered(1.0, 2.0); fprintf( stdout, "isunordered : %d\n", i1); f1 = j0l(1.2); fprintf( stdout, "j0l : %Lf\n", f1); f1 = j1l(1.2); fprintf( stdout, "j1l : %Lf\n", f1); f1 = jnl(2,1.2); fprintf( stdout, "jnl : %Lf\n", f1); f1 = ldexpl(1.2,3); fprintf( stdout, "ldexpl : %Lf\n", f1); f1 = lgammal(42.0); fprintf( stdout, "lgammal : %Lf\n", f1); f1 = llrintl(-0.5); fprintf( stdout, "llrintl : %Lf\n", f1); f1 = llrintl(0.5); fprintf( stdout, "llrintl : %Lf\n", f1); f1 = llroundl(-0.5); fprintf( stdout, "lroundl : %Lf\n", f1); f1 = llroundl(0.5); fprintf( stdout, "lroundl : %Lf\n", f1); f1 = logl(42.0); fprintf( stdout, "logl : %Lf\n", f1); f1 = log10l(42.0); fprintf( stdout, "log10l : %Lf\n", f1); f1 = log1pl(42.0); fprintf( stdout, "log1pl : %Lf\n", f1); f1 = log2l(42.0); fprintf( stdout, "log2l : %Lf\n", f1); f1 = logbl(42.0); fprintf( stdout, "logbl : %Lf\n", f1); f1 = lrintl(-0.5); fprintf( stdout, "lrintl : %Lf\n", f1); f1 = lrintl(0.5); fprintf( stdout, "lrintl : %Lf\n", f1); f1 = lroundl(-0.5); fprintf( stdout, "lroundl : %Lf\n", f1); f1 = lroundl(0.5); fprintf( stdout, "lroundl : %Lf\n", f1); f1 = modfl(42.0,&f2); fprintf( stdout, "lmodfl : %Lf\n", f1); f1 = nanl(""); fprintf( stdout, "nanl : %Lf\n", f1); f1 = nearbyintl(1.5); fprintf( stdout, "nearbyintl : %Lf\n", f1); f1 = nextafterl(1.5,2.0); fprintf( stdout, "nextafterl : %Lf\n", f1); f1 = powl(3.01, 2.0); fprintf( stdout, "powl : %Lf\n", f1); f1 = remainderl(3.01,2.0); fprintf( stdout, "remainderl : %Lf\n", f1); f1 = remquol(29.0,3.0,&i1); fprintf( stdout, "remquol : %Lf\n", f1); f1 = rintl(0.5); fprintf( stdout, "rintl : %Lf\n", f1); f1 = rintl(-0.5); fprintf( stdout, "rintl : %Lf\n", f1); f1 = roundl(0.5); fprintf( stdout, "roundl : %Lf\n", f1); f1 = roundl(-0.5); fprintf( stdout, "roundl : %Lf\n", f1); f1 = scalblnl(1.2,3); fprintf( stdout, "scalblnl : %Lf\n", f1); f1 = scalbnl(1.2,3); fprintf( stdout, "scalbnl : %Lf\n", f1); /* no type-specific variant */ i1 = signbit(1.0); fprintf( stdout, "signbit : %i\n", i1); f1 = sinl(M_PI_4); fprintf( stdout, "sinl : %Lf\n", f1); f1 = sinhl(M_PI_4); fprintf( stdout, "sinhl : %Lf\n", f1); f1 = sqrtl(9.0); fprintf( stdout, "sqrtl : %Lf\n", f1); f1 = tanl(M_PI_4); fprintf( stdout, "tanl : %Lf\n", f1); f1 = tanhl(M_PI_4); fprintf( stdout, "tanhl : %Lf\n", f1); f1 = tgammal(2.1); fprintf( stdout, "tgammal : %Lf\n", f1); f1 = truncl(3.5); fprintf( stdout, "truncl : %Lf\n", f1); f1 = y0l(1.2); fprintf( stdout, "y0l : %Lf\n", f1); f1 = y1l(1.2); fprintf( stdout, "y1l : %Lf\n", f1); f1 = ynl(3,1.2); fprintf( stdout, "ynl : %Lf\n", f1); #endif }
void CMainWnd::OnPaint() { Object A{ 2.680795435464e+20, -1.531367579292792e+12, 0.0, 0.0, -1.923828617202e+3 * M_PI / 1.581035760 * sqrtl(5.1/19.9), 0.0, 0.0, 1.40491e+9 }; Object B{ 1.2979296712296e+20, 3.19134145606896e+12, 0.0, 0.0, 4.009222934760e+3 * M_PI / 1.581035760 * sqrtl(5.1 / 19.9), 0.0, 0.0, 5.8422e+7 }; CPaintDC dc(this); RECT rect; GetClientRect(&rect); long double x = rect.right; //Ширина окна long double y = rect.bottom; //Высота окна dc.FillSolidRect(0, 0, lrintl(x), lrintl(y), RGB(0, 0, 0)); CPen Line(PS_SOLID, 1, RGB(255, 255, 255)); CBrush Star1(RGB(255,255,255)); CBrush Star2(RGB(0, 0, 0)); CBrush BPlanetoid(RGB(0, 127, 127)); CPen Planetoid(PS_SOLID, 1, RGB(0, 127, 127)); CPen Background(PS_SOLID, 1, RGB(0, 0, 0)); dc.SetTextColor(RGB(255, 255, 255)); dc.TextOutW(5, 5, "Координаты планеты, а.е."); dc.TextOutW(5, 65, "Скорость планеты, км/с"); long double h = 5.0e+4; long double max = 3.2e+12; dc.MoveTo(lrintl(x / 2 + y / 2.0*A.x / max), lrintl(y / 2.0*(1.0 - A.y / max))); for (long double t = 0; t < T; t += h){ long double dx = B.x - A.x, dy = B.y - A.y; long double R = hypotl(dx, dy); long double cosinus = dx / R, sinus = dy / R; R *= R; // Сириус А A.ax = B.GM / R * cosinus; A.ay = B.GM / R * sinus; A.vx += h*A.ax; A.vy += h*A.ay; // Сириус Б B.ax = -A.GM / R * cosinus; B.ay = -A.GM / R * sinus; B.vx += h*B.ax; B.vy += h*B.ay; dx = Planet.x - A.x, dy = Planet.y - A.y; R = hypotl(dx, dy); cosinus = dx / R; sinus = dy / R; R *= R; Planet.ax = -A.GM / R * cosinus; Planet.ay = -A.GM / R * sinus; dx = Planet.x - B.x; dy = Planet.y - B.y; R = hypotl(dx, dy); cosinus = dx / R; sinus = dy / R; R *= R; Planet.ax += -B.GM / R * cosinus; Planet.ay += -B.GM / R * sinus; Planet.vx += h*Planet.ax; Planet.vy += h*Planet.ay; bool k = (llrintl(t) % 1000 == 0); if (k){ dc.SelectObject(Line); dc.MoveTo(0, lrintl(y / 2)); dc.LineTo(lrintl(x), lrintl(y / 2)); dc.MoveTo(lrintl(x / 2), 0); dc.LineTo(lrintl(x / 2), lrintl(y)); }; if (k){ dc.SelectObject(Background); dc.SelectObject(Star2); dc.Ellipse(lrintl(x / 2 + y / 2.0*A.x / max) - 7, lrintl(y / 2.0*(1.0 - A.y / max)) - 7, lrintl(x / 2 + y / 2.0*A.x / max) + 7, lrintl(y / 2.0*(1.0 - A.y / max)) + 7); }; A.x += h*A.vx; A.y += h*A.vy; if (k){ dc.SelectObject(Star1); dc.Ellipse(lrintl(x / 2 + y / 2.0*A.x / max) - 7, lrintl(y / 2.0*(1.0 - A.y / max)) - 7, lrintl(x / 2 + y / 2.0*A.x / max) + 7, lrintl(y / 2.0*(1.0 - A.y / max)) + 7); }; //dc.LineTo(lrintl(x / 2 + y / 2.0*A.x / max), lrintl(y / 2.0*(1.0 - A.y / max))); //dc.MoveTo(lrintl(x / 2 + y / 2.0*B.x / max), lrintl(y / 2.0*(1.0 - B.y / max))); if (k){ dc.SelectObject(Background); dc.SelectObject(Star2); dc.Ellipse(lrintl(x / 2 + y / 2.0*B.x / max) - 5, lrintl(y / 2.0*(1.0 - B.y / max)) - 5, lrintl(x / 2 + y / 2.0*B.x / max) + 5, lrintl(y / 2.0*(1.0 - B.y / max)) + 5); }; B.x += h*B.vx; B.y += h*B.vy; if (k){ dc.SelectObject(Star1); dc.Ellipse(lrintl(x / 2 + y / 2.0*B.x / max) - 5, lrintl(y / 2.0*(1.0 - B.y / max)) - 5, lrintl(x / 2 + y / 2.0*B.x / max) + 5, lrintl(y / 2.0*(1.0 - B.y / max)) + 5); }; if (k){ dc.SelectObject(Background); dc.SelectObject(Star2); dc.Ellipse(lrintl(x / 2 + y / 2.0*Planet.x / max) - 3, lrintl(y / 2.0*(1.0 - Planet.y / max)) - 3, lrintl(x / 2 + y / 2.0*Planet.x / max) + 3, lrintl(y / 2.0*(1.0 - Planet.y / max)) + 3); }; Planet.x += h*Planet.vx; Planet.y += h*Planet.vy; if (k){ dc.SelectObject(BPlanetoid); dc.Ellipse(lrintl(x / 2 + y / 2.0*Planet.x / max) - 3, lrintl(y / 2.0*(1.0 - Planet.y / max)) - 3, lrintl(x / 2 + y / 2.0*Planet.x / max) + 3, lrintl(y / 2.0*(1.0 - Planet.y / max)) + 3); }; if ((hypotl(Planet.x - A.x, Planet.y - A.y) < A.R + Planet.R) || (hypotl(Planet.x - B.x, Planet.y - B.y) < B.R + Planet.R) || (fabsl(x/2.0*Planet.x / max)>x) || (fabsl(y/2.0*Planet.y / max)>y)) break; /* //dc.LineTo(lrintl(x / 2 + y / 2.0*B.x / max), lrintl(y / 2.0*(1.0 - B.y / max))); dc.SelectObject(Planetoid); dc.MoveTo(lrintl(x / 2 + y / 2.0*Planet.x / max), lrintl(y / 2.0*(1.0 - Planet.y / max))); Planet.x += h*Planet.vx; Planet.y += h*Planet.vy; dc.LineTo(lrintl(x / 2 + y / 2.0*Planet.x / max), lrintl(y / 2.0*(1.0 - Planet.y / max))); //dc.MoveTo(lrintl(x / 2 + y / 2.0*A.x / max), lrintl(y / 2.0*(1.0 - A.y / max))); */ } }
static int testl(long double long_double_x, int int_x, long long_x) { int r = 0; r += __finitel(long_double_x); r += __fpclassifyl(long_double_x); r += __isinfl(long_double_x); r += __isnanl(long_double_x); r += __signbitl(long_double_x); r += acoshl(long_double_x); r += acosl(long_double_x); r += asinhl(long_double_x); r += asinl(long_double_x); r += atan2l(long_double_x, long_double_x); r += atanhl(long_double_x); r += atanl(long_double_x); r += cbrtl(long_double_x); r += ceill(long_double_x); r += copysignl(long_double_x, long_double_x); r += coshl(long_double_x); r += cosl(long_double_x); r += erfcl(long_double_x); r += erfl(long_double_x); r += exp2l(long_double_x); r += expl(long_double_x); r += expm1l(long_double_x); r += fabsl(long_double_x); r += fdiml(long_double_x, long_double_x); r += floorl(long_double_x); r += fmal(long_double_x, long_double_x, long_double_x); r += fmaxl(long_double_x, long_double_x); r += fminl(long_double_x, long_double_x); r += fmodl(long_double_x, long_double_x); r += frexpl(long_double_x, &int_x); r += hypotl(long_double_x, long_double_x); r += ilogbl(long_double_x); r += ldexpl(long_double_x, int_x); r += lgammal(long_double_x); r += llrintl(long_double_x); r += llroundl(long_double_x); r += log10l(long_double_x); r += log1pl(long_double_x); r += log2l(long_double_x); r += logbl(long_double_x); r += logl(long_double_x); r += lrintl(long_double_x); r += lroundl(long_double_x); r += modfl(long_double_x, &long_double_x); r += nearbyintl(long_double_x); r += nextafterl(long_double_x, long_double_x); r += nexttowardl(long_double_x, long_double_x); r += powl(long_double_x, long_double_x); r += remainderl(long_double_x, long_double_x); r += remquol(long_double_x, long_double_x, &int_x); r += rintl(long_double_x); r += roundl(long_double_x); r += scalblnl(long_double_x, long_x); r += scalbnl(long_double_x, int_x); r += sinhl(long_double_x); r += sinl(long_double_x); r += sqrtl(long_double_x); r += tanhl(long_double_x); r += tanl(long_double_x); r += tgammal(long_double_x); r += truncl(long_double_x); return r; }
long long int test12l(long double x) { return llrintl(x); }
long int __lrintl (long double d) { return llrintl (d); }