"P1203" Buy flowers

Source: Internet
Author: User

I have been weak to even high-precision by the single fine can write the point of error Qaq

Original question:

A number m less than or equal to N, which makes Phi (m)/m the smallest,
where Phi (m) is the number with M coprime and smaller than M.
For example phi (4) = 2, because 1,3 and 4 coprime.

N<=10^40

First, the Euler function of the table, found that the answer must be the product <=m the first k prime number of the product (such as 50 of the answer is 2*3*5<=50)

Then there's the high-precision water.

However I wrote 2h Qaq, and sure enough the strength is going to decrease over time qaq

The main error is about the length of the result of the problem, the length of the a[i]>=10 back when pushed to push the edge of the update, can not be all finished before the update, because after the push may be due to%=10 and there is a 0 of the situation, this time pushing the length of the broken, But this is not the case with push-side updates, because it's not%=10 and ==0

I'm so weak, Qaq.

Code:

1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <cstring>5#include <cmath>6 using namespacestd;7 voidRead_big (int*x,int&AMP;LX) {lx=0;CharCh=GetChar ();8      while(ch<'0'|| Ch>'9') ch=GetChar ();9      while(ch>='0'&&ch<='9') {x[++lx]=ch-'0'; Ch=GetChar ();}Ten } One intn[ the],ln; A inta[ the],la,b[ the],lb,c[ the]; - BOOLkang[1100000];intzhi[1100000],ztop=0; - voidShai () { thememset (Kang,0,sizeof(Kang)); -      for(intI=2; i<=1000000; i++)if(!Kang[i]) { -zhi[++ztop]=i; -         inttemp=1; while(I* (temp+1) <=1000000) kang[i* (++temp)]=true; +     } - } + BOOLBiint*x,intLxint*y,intly) { A     if(lx!=ly)return(lx>ly); at      for(inti=lx;i>=1; i--)if(X[i]!=y[i])return(x[i]>y[i]); -     return false; - } - voidChengint*x,int&AMP;LX,inty) { -      for(intI=1; i<=lx;i++) x[i]*=y; -      for(intI=1; i<=lx;i++) x[i+1]+=x[i]/Ten, x[i]%=Ten; in      for(; a[lx+1];lx++) x[lx]+=x[lx]/Ten, x[lx]%=Ten; - } to intMain () {//freopen ("ddd.in", "R", stdin); + Shai (); - Read_big (C,LN); the      for(inti=ln;i>=1; i--) n[i]=c[ln-i+1]; *A[la=1]=1; $      for(intI=1; i<=10000; i++){Panax Notoginsenglb=LA; -          for(intj=1; j<=lb;j++) b[j]=A[j]; the Cheng (a,la,zhi[i]); +         if(Bi (A,LA,N,LN)) { for(intj=lb;j>=1; j--) cout<<b[j]; cout<<endl;return 0;} A     } the     return 0; +}
View Code

"P1203" Buy flowers

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.