A. Little Pony and crystal mine
Question: Output something similar to a cross
Question: Print it directly...
Code:
1 var n,i,j:longint; 2 begin 3 readln(n); 4 for i:=1 to n>>1 do 5 begin 6 for j:=1 to (n-i<<1+1)>>1 do write(‘*‘); 7 for j:=1 to i<<1-1 do write(‘D‘); 8 for j:=1 to (n-i<<1+1)>>1 do write(‘*‘); 9 writeln;10 end;11 for i:=1 to n do write(‘D‘);writeln;12 for i:=n>>1 downto 1 do13 begin14 for j:=1 to (n-i<<1+1)>>1 do write(‘*‘);15 for j:=1 to i<<1-1 do write(‘D‘);16 for j:=1 to (n-i<<1+1)>>1 do write(‘*‘);17 writeln;18 end;19 end.20
View code
B. Little Pony and sort by shift
Question: Give You A series. You can adjust the last number to the first number each time, and find the minimum number of times required to change this series to monotonic increase.
Problem: copy the original series to the back and use a temporary variable to record the answer from the beginning.
Code:
1 var n,i,cnt:longint; 2 a:array[0..250000] of longint; 3 begin 4 readln(n); 5 a[0]:=maxlongint; 6 for i:=1 to n do read(a[i]); 7 for i:=1 to n do a[n+i]:=a[i]; 8 cnt:=0; 9 for i:=1 to n<<1 do10 if a[i]>=a[i-1] then11 begin12 inc(cnt);13 if cnt=n-1 then break;14 end15 else cnt:=0;16 if cnt<>n-1 then writeln(‘-1‘)17 else if i=n then writeln(‘0‘)18 else writeln(n<<1-i);19 end.
View code
CDE didn't look at it... Or you can't see it...