Constructs Codeforces Round #135 (Div. 2) B. Special offer! Super Price 999 bourles!

Source: Internet
Author: User

Topic Portal

1 /*2 construction: From large to small structure, each time the last is not 9 into 9,p-p MOD 10^k-1, until less than the minimum value. 3 In addition, up to len-1 cycles4 */5#include <cstdio>6#include <algorithm>7#include <cstring>8#include <cmath>9 using namespacestd;Ten  OnetypedefLong Longll; A Const intMAXN = 1e3 +Ten; - Const intINF =0x3f3f3f3f; -  the intGet_len (ll x) { -     intRET =0; -      while(x) { -X/=Ten; ret++; +     } -     returnret; + } A  at intGet_nine (ll x) { -     intRET =0; -      while(x) { -ll y = x%Ten; X/=Ten; -         if(Y! =9) Break; -ret++; in     } -     returnret; to } +  - intMainvoid)  {//codeforces Round #135 (Div. 2) B. Special offer! Super Price 999 bourles! the     //freopen ("c.in", "R", stdin); *      $ ll P, D;Panax Notoginseng      while(SCANF ("%i64d%i64d", &p, &d) = =2)   { -         intlen = Get_len (p); ll now =p; the         intmx = Get_nine (p); ll ans =p; +ll cut =1; A          while(true)    { thell y = now/cut%Ten; +             if(Y! =9) { -now = Now-cut *Ten; now = Now/cut + Cut-1; $             } $Cut *=Ten; -             if(Now < p-d) Break; -             intCNT =Get_nine (now); the             if(cnt > mx) ans =Now ; -         }Wuyi  theprintf ("%i64d\n", ans); -     } Wu  -     return 0; About}

Constructs Codeforces Round #135 (Div. 2) B. Special offer! Super Price 999 bourles!

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.