http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4888
Title two parameters, path: Enumeration of small parameters, and then binary large parameters
Think about two points. It's not going to happen again. Two parameters then in the violence, the K can be very large, so time is not enough
Write your own two-point enumeration + high-speed Power program WA for a very long time.
。。
。 Not clear where the wrong to take the test of others ...
#pragma COMMENT (linker, "/stack:102400000,102400000") #include <cstdio> #include <cstring> #include < algorithm> #include <string> #include <iostream> #include <iomanip> #include <cmath># Include <map> #include <set> #include <queue>using namespace std; #define LS (RT) Rt*2#define RS (RT) rt*2 +1#define ll Long long#define ull unsigned long long#define rep (i,s,e) for (int. i=s;i<e;i++) #define REPE (i,s,e) for (int i=s;i<=e;i++) #define CL (A, B) memset (A,b,sizeof (a)) #define in (s) freopen (S, "R", stdin) #define OUT (s) freopen (S, "w", STDOUT) const LL ll_inf = ((ull) ( -1)) >>1;const double EPS = 1e-8;const double pi = ACOs ( -1.0); const int INF = 1000000 00;ll n,ansr,ansk;void Test (ll D, ll up, int r) {ll sum; while (D<up) {ll mid= (d+up)/2; sum=0; ll Know=1;//k^i int flag=0; for (int i=1;i<=r;i++) {know*=mid; Sum+=know; if (SUM>1000000000000LL | | sum<0) {flag=1; Break }} if (flag) {up=mid; Continue } if (sum>n) Up=mid; else d=mid+1; if (sum+1 = = N | | sum==n) {if (Mid*r < Ansr*ansk) Ansr=r,ansk=mid; Break }}}int Main () {in ("Zoj3665.txt"); while (~SCANF ("%lld", &n)) {ansr=1; ansk=n-1;//for (int i=2;i<=64;i++) test (1ll,1000000,i); printf ("%lld%lld\n", Ansr,ansk); } return 0;}
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Zoj 3665 number Theory two-way two parameters