"Bzoj" "1053" "HAOI2007" anti-prime ant

Source: Internet
Author: User

Search

Classic Search topic (in fact, Konjac Konjac will only search ... vfleaking seems to have better practices? )

Enumerate the powers of prime numbers, in fact not much depth ... Because the $2^32$ is more than n ... And the prime number can not be taken too big, so will not explode ...

1 /**************************************************************2 problem:10533 User:tunix4 language:c++5 result:accepted6 time:40 Ms7 memory:1760 KB8 ****************************************************************/9  Ten //Bzoj 1053 One#include <cmath> A#include <vector> -#include <cstdio> -#include <cstring> the#include <cstdlib> -#include <iostream> -#include <algorithm> - #defineRep (i,n) for (int i=0;i<n;++i) + #defineF (i,j,n) for (int i=j;i<=n;++i) - #defineD (i,j,n) for (int i=j;i>=n;--i) + #definePB Push_back A using namespacestd; atInlineintGetint () { -     intv=0, sign=1;CharCh=GetChar (); -      while(ch<'0'|| Ch>'9'){if(ch=='-') sign=-1; Ch=GetChar ();} -      while(ch>='0'&&ch<='9') {v=v*Ten+ch-'0'; Ch=GetChar ();} -     returnv*Sign ; - } in Const intn=2e9,inf=~0u>>2; -typedefLong LongLL; to /******************tamplate*********************/ + intn,prime[100010],tot; -LL mx=0, ans=0; the BOOLvis[100010]; * //First x prime number, the total product is now, because several numbers are M $ voidDfsintX,ll Now,ll m,intLim) {Panax Notoginseng     if(M>mx && now<=N) { -Mx=m; cn1=Now ; the     } +     if(m==mx && Now<ans && now<=n) ans=Now ; A     if(x> -)return; theLL p=Now ; +F (I,1, Lim) { -         if(p*prime[x]>n) Break; $p*=Prime[x]; $DFS (x+1, p,m* (i+1), lim-i); -     } - } the intMain () { - #ifndef Online_judgeWuyiFreopen ("1053.in","R", stdin); theFreopen ("1053.out","W", stdout); - #endif Wuscanf"%d",&n); -F (I,2, sqrt (N)) { About         if(!Vis[i]) { $prime[++tot]=i; -              for(intJ=I*I;J&LT;=SQRT (N); j+=i) vis[j]=1; -         } -     } ADfs1,1,1, -); +printf"%lld\n", ans); the     return 0; -}
View Code 1053: [HAOI2007] anti-prime ant time limit:10 Sec Memory limit:162 MB
submit:1821 solved:1014
[Submit] [Status] [Discuss] Description

For any positive integer x, the number of its approximate numbers is recorded as g (x). For example G (1) =1, g (6) = 4.
If a positive integer x satisfies: g (x) >g (i) 0<i<x, it is said that X is an inverse prime number. For example, integer 1,2,4,6, etc. are all anti-prime.
Now given a number n, can you find the largest anti-prime that does not exceed n?

Input

A number N (1<=n<=2,000,000,000).

Output

The maximum number of anti-prime numbers not exceeding N.

Sample Input +Sample Output840Hintsource [Submit] [Status] [Discuss]

"Bzoj" "1053" "HAOI2007" anti-prime ant

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.