Codeforces Round #204 (Div. 2)
Problems
懒得说太多。
Problem A:恶俗小学数学题……不过虐我足够了,写了9min。因为要求被90整除,分解一下90=10*9。然后就好做了,一定“0”结尾,没有的滚……然后判断是否各位和a满足,9|a,然后乱搞一下,就这样。写完这题,目测200名……
Problem B:满水的T,不过英语渣不说话,今早才发现理解有点问题。迅速搞一搞。嗯,其实也不是什么能说太多的T,只能说英语不要太渣,明确各个变量作用就行了。
Problem C:一开始理解错了……后来才发现真正意思,最初想法是贪心,先排序,小数部分0和0.5的向上、向下去整和原来差一样,主要考虑其他的分配。小于0.5的自然向下,大于0.5的自然向上,这样差别最小。因为向上、向下各有n次操作,将向上、向下操作看成两个组,问题就是如何分配小数部分为0和0.5的到两个组,将某个组多余元素挤到另一个组,使两个组元素都为n个(qsort一下,看起来更简单)。不过码起来有点麻烦。考虑整数部分没什么用,所以将所有数向下取整,然后枚举向上取整的数目,将原小数部分和与枚举值减一下取最小值,就出来了。值得注意的是FPC比较作,小数0.68 这样的它会在读取后储存为0.6899999999……,直接取小数部分不行,需要trunc(round(frac(a)*1000))的操作。
1 program ta; 2 var 3 a,n,i:integer; 4 c:array [0..5] of integer; 5 begin 6 readln(n); 7 fillchar(c,sizeof(c),0); 8 for i:=1 to n do begin 9 read(a);inc(c[a]); 10 end; 11 if c[0]=0 then writeln(-1) 12 else begin 13 a:=0; 14 for i:=c[5] downto 1 do 15 if i*5 mod 9=0 then begin;a:=i;break;end; 16 for i:=1 to a do write(5); 17 if a=0 then c[0]:=1; 18 for i:=1 to c[0] do write(0); 19 writeln; 20 end; 21 end.
1 program tb; 2 var 3 ans,a,n,i:longint; 4 p,b:array [1..100000] of longint; 5 begin 6 readln(n); 7 for i:=1 to 100000 do b[i]:=maxlongint; 8 for i:=1 to n do begin 9 read(a); 10 if b[a]=-1 then continue; 11 if p[a]=0 then 12 b[a]:=0 13 else begin 14 if b[a]=0 then 15 b[a]:=i-p[a] 16 else 17 if i-p[a]<>b[a] then b[a]:=-1; 18 end; 19 p[a]:=i; 20 end; 21 for i:=1 to 100000 do 22 if (b[i]>-1) and (b[i]<maxlongint) then inc(ans); 23 writeln(ans); 24 for i:=1 to 100000 do 25 if (b[i]>-1) and (b[i]<maxlongint) then writeln(i,' ',b[i]); 26 end.
1 program tc; 2 var 3 n,c0,i:integer; 4 a:real; 5 ans,sum:longint; 6 begin 7 readln(n);c0:=0;sum:=0; 8 for i:=1 to 2*n do begin 9 read(a); 10 if a-trunc(a)<0.0000001 then inc(c0); 11 inc(sum,trunc(round(frac(a)*1000))); 12 end; 13 ans:=maxlongint; 14 for i:=0 to n do begin 15 if c0+i<n then continue; 16 if ans>abs(i*1000-sum) then ans:=abs(i*1000-sum); 17 end; 18 writeln((ans/1000):0:3); 19 end.