UVA11549 Calculator Conundrum Calculator puzzle

Source: Internet
Author: User

It is thought that the violence of the solution time complexity should be very high, maybe the cycle will be relatively small bar

The better harvest is this Floyd.

  

#include <Set>#include<cstdio>#include<iostream>#include<algorithm>using namespaceStd;typedefLong LongLL;Const intMAXN =100005;Const intINF =0x3f3f3f3f; LL POW10 (intN) {LL ans=1;  for(inti =1; i<=n;++i) ans*=Ten; returnans;} LL m; ll next (ll K) {k*=K;  while(k>=m) k/=Ten; returnK;}intMain () {//freopen ("In.txt", "R", stdin);    intT;SCANF ("%d",&T);  while(t--) {LL n,k; CIN>>n>>K; M=POW10 (n); LL K1= K,K2 = K,ans =K;  Do{K1=next (K1); K2= Next (K2); ans=Max (ANS,K2); K2= Next (K2); ans=Max (ANS,K2); }         while(k1!=K2); cout<<ans<<Endl; }    return 0;}

UVA11549 Calculator Conundrum Calculator puzzle

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.