1樓:匿名使用者
program gfgff
vari,j,n,c:longint;
t:qword;
a:array[0..300000]of longint;
b:array[0..300000]of int64;
procedure swap(var a,b:longint);
vartemp:longint;
begin
temp:=a;
a:=b;
b:=temp;
end;
procedure sort(l,r:longint);
vari,j,x:longint;
begin
i:=l;j:=r;x:=a[(l+r)shr 1];
repeat
while a[i]x do dec(j);
if i<=j then
begin
swap(a[i],a[j]);
inc(i);dec(j);
end;
until i>j;
if l=r;
if (a[l]=x)and(l<=n) then exit(l);
if (a[r]=x)and(r>=1) then exit(r);
exit(0);
end;
begin
assign(input,'dec.in');reset(input);
readln(n,c);
for i:=1 to n do read(a[i]);
close(input);
sort(1,n);
j:=0;
a[0]:=a[1]-1;
for i:=1 to n do
begin
if a[i]=a[i-1] then inc(j);
a[i-j]:=a[i];
inc(b[i-j]);
end;
n:=n-j;
t:=0;
if c=0 then
for i:=1 to n do
t:=t+b[i]*(b[i]-1)div 2else
for i:=1 to n do
begin
t:=t+b[i]*b[find(c+a[i])];
writeln(find(c+a[i]));
end;
for i:=1 to n do writeln(a[i],' ',b[i]);
assign(output,'dec.out');rewrite(output);
writeln(t);
close(output);
end.
2樓:巧克力
1.var
i,j,n,c:longint;
t:qword;
a:array[0..300000]of longint;
b:array[0..300000]of int64;
procedure swap(var a,b:longint);
vartemp:longint;
begin
temp:=a;
a:=b;
b:=temp;
end;
procedure sort(l,r:longint);
vari,j,x:longint;
begin
i:=l;j:=r;x:=a[(l+r)shr 1];
repeat
while a[i]x do dec(j);
if i<=j then
begin
swap(a[i],a[j]);
inc(i);dec(j);
end;
until i>j;
if l=r;
if (a[l]=x)and(l<=n) then exit(l);
if (a[r]=x)and(r>=1) then exit(r);
exit(0);
end;
begin
assign(input,'dec.in');reset(input);
readln(n,c);
for i:=1 to n do read(a[i]);
close(input);
sort(1,n);
j:=0;
a[0]:=a[1]-1;
for i:=1 to n do
begin
if a[i]=a[i-1] then inc(j);
a[i-j]:=a[i];
inc(b[i-j]);
end;
n:=n-j;
t:=0;
if c=0 then
for i:=1 to n do
t:=t+b[i]*(b[i]-1)div 2
else
for i:=1 to n do
begin
t:=t+b[i]*b[find(c+a[i])];
// writeln(find(c+a[i]));
end;
// for i:=1 to n do writeln(a[i],' ',b[i]);
assign(output,'dec.out');rewrite(output);
writeln(t);
close(output);
end.
2.var
tot,n,i,j,n1:longint;
pre,next,b,a:array[0..20]of longint;
l,r,s:array[-20..20]of longint;
ch:char;
procedure try(deep,y,z:longint);
vari:longint;
begin
if deep>n then
begin
inc(tot);
exit;
end;
i:=next[0];
repeat
if a[deep] and s[i]<>0 then
if y and l[deep+i]<>0 then
if z and r[deep-i]<>0 then
begin
pre[next[i]]:=pre[i];
next[pre[i]]:=next[i];
try(deep+1,y xor l[deep+i],z xor r[deep-i]);
next[pre[i]]:=i;
pre[next[i]]:=i;
end;
i:=next[i];
until i>n;
end;
begin
assign(input,'queens.in');reset(input);
readln(n);
for i:=1 to n do
begin
for j:=1 to n do
begin
read(ch);
if ch='*' then
a[i]:=a[i] xor (1 shl (j-1));
end;
readln;
end;
close(input);
for i:=0 to n+1 do
next[i]:=i+1;
for i:=0 to n+1 do
pre[i]:=i-1;
n1:=1 shl n-1;
b[n+1]:=n1;
for i:=n downto 1 do
b[i]:=b[i+1] or a[i];
for i:=1 to n do
s[i]:=1 shl (i-1);
r[1-n]:=1;
for i:=1-n+1 to n-1 do
r[i]:=r[i-1] shl 1;
l[1+1]:=1;
for i:=1+1+1 to n+n do
l[i]:=l[i-1] shl 1;
try(1,1 shl (n+n-1)-1,1 shl (n+n-1)-1);
assign(output,'queens.out');rewrite(output);
writeln(tot);
close(output);
end.
求解幾道英語題
3樓:一線口語
8-12 abcbc
4樓:匿名使用者
8 b9 b
10 a
11 b
12 a
5樓:我叫鄰家小夥伴
abcbc,差不多就是這樣啦
幾道c語言的題,求解,幾道C語言的題,求解
生秋 第一題 include int main 第二題 include include int main 第三題邏輯沒錯,不過忘記加 費了 include include int main 第四題 include include int main 第五題測試資料沒加逗號的,相加可以修改scanf i...
請教幾道英語題,求解幾道英語題
粒籽遊靈 2.b是動詞c是名詞 3.可數 可能是因為原題material是單數形式,所以這個短語為單數。字典上說material這個單詞既可數又不可數,根據情況 deer是集合名詞,此處表示的是複數概念,與後面的dogs相對應,所以選d b和c一為動詞一為名詞 half of the materia...
幾道sat語法題求解
你好第乙個 demand引導的是乙個賓語從句,此句省略了that,所以we做從句中的主語,使句子成分完整。第二個首先,thereby後的depriving是做乙個原因狀語從句,它的主語是trace newrotic symptoms back to their unconscious roots a...