Codeforces round #259 (Div. 2)

Source: Internet
Author: User

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...

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.