Zoj 3665 number Theory two-way two parameters

Source: Internet
Author: User

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&GT;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.