"Nowcoder" 4th T1 Dynamic Point Division

Source: Internet
Author: User

Title Link: Https://www.nowcoder.com/acm/contest/175/A

Topic name scare

Std

I

It's too much to be snapped.

A simple simulation problem. even though I thought test instructions wrong. .

Follow test instructions to simulate output and inheritance.

WA point: Because the data K range is within 263 (long long:263-1,unsigned long long int:264-1)

So it'll be easy to explode.

will also explode back into the [l,r] range, WA

How to avoid it?

First assume that X is an inherited value

Then every change is x=x*k.

If the range of each change is within the range of r/k, then the explosion can be avoided.

The code is as follows:

1#include <bits/stdc++.h>2 #definell Long Long3 using namespacestd;4 5 intN;6 ll L,r,k,x;7 BOOLcheck=false;8 9 ll Read () {Tenll xxx=0, fff=1;CharCh=GetChar (); One      while(ch>'9'|| ch<'0'){if(ch=='-') fff=-1; ch=GetChar ();} A      while(ch<='9'&&ch>='0') {xxx= (xxx<<3) + (xxx<<1) +ch-'0'; ch=GetChar ();} -     returnxxx*FFF; - } the  - intMain () { -n=Read (); -      while(n--){ +L=read (); R=read (); k=Read (); -check=false; +         Switch(k) { A              Case 0:if(l<=0&&r>=0){ atPutchar ('0');p Utchar (' '); -check=true; -             } -              Case 1:if(l<=1&&r>=1){ -Putchar ('1');p Utchar (' '); -check=true; in                  -             } to              Break; +             default: for(x=1;;) { -                 if(l<=x&&x<=r) { theprintf"%lld", x); *check=true; $                 }Panax Notoginseng                 if(x<=r/k) x*=k;Else  Break; -             } the         } +         if(!check) { APuts"None."); the         } +         ElsePutchar ('\ n'); -     } $     return 0; $}

PE several times later only to know puts () Auto line wrapping

"Nowcoder" 4th T1 Dynamic Point Division

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.