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