2193 so hard
Test instructions
Simplify decimals.
Ideas:
No more than 9 bits, then multiply 10^9 just fine.
Then note that the accuracy is added.
Code:
#include "cstdlib" #include "Cstdio" #include "CString" #include "Cmath" #include "queue" #include "algorithm" #include " iostream "#include" map "#define LL __int64#define eps 1e-11using namespace std;ll gcd (ll a,ll b) { return b==0?a:gcd (b, A%B);} int main () { int t; cin>>t; while (t--) { double x; scanf ("%lf", &x); ll fz= (LL) ((x+eps) *1000000000); ll fm=1000000000; ll TEP=GCD (FZ,FM); printf ("%i64d/%i64d\n", Fz/tep,fm/tep); } return 0;}
2191 the perfect number
Test instructions
The perfect degree of each number within the [a, b] interval.
The so-called perfect degree is the number of a*a*b (0<A<=B) that x can break down into.
Ideas:
Within the [1,x] interval.
We enumerate A.
Because a<=b for each I, so to set up, the smallest number is I*i*i
However, we just have to judge how many i*i are in the range of i*i*i<=x.
For each i*i-i+1.
Then subtract.
Code:
#include "cstdlib" #include "Cstdio" #include "CString" #include "Cmath" #include "queue" #include "algorithm" #include " iostream "#include" map "#define LL __int64#define EPS 1e-11using namespace std;int main () { ll x, y; while (scanf ("%i64d%i64d", &x,&y)!=-1) { ll ansx=0,ansy=0; x--; for (ll i=1;i*i*i<=x;i++) ansx+=x/(i*i)-i+1; for (ll i=1;i*i*i<=y;i++) ansy+=y/(i*i)-i+1; printf ("%i64d\n", ANSY-ANSX); } return 0;}
[Water + math] Fzu OJ 2193 so hard and 2191 perfect numbers