158 条题解
-
0SecretAgent LV 10 @ 2009-09-21 23:45:01
闷,多打印了一个变量交了2次.
只要冒泡排序2次就可以了 -
02009-09-18 18:13:22@
何等水题!!
#include
struct d
{
int chinese,math,english;
int sign,grade;
}a[10000];
int com(struct d a1,struct d a2)
{
if(a1.grade -
02009-09-18 11:45:14@
#include
#include
using namespace std;bool rule(int *a,int *b)
{
bool t = false;
t = a[1]+a[2]+a[3] == b[1]+b[2]+b[3];
if(t == false)
return a[1]+a[2]+a[3] > b[1]+b[2]+b[3];
else
{
t = a[1] == b[1];
if(t == false)
return a[1] > b[1];
else
return a[0] < b[0];
}
}
int main()
{
int n;
cin >> n;
int a[1000][4];
int temp;
for(int i = 1;i > a[i][1];
cin >> a[i][2];
cin >> a[i][3];
}
for(int i = 1;i -
02009-09-13 10:15:58@
N的范围是多大啊?
-
02009-09-11 21:31:47@
经本人提交N……100000000000次后 精确测定 n
-
02009-09-08 17:32:52@
program P1398
var i,j,k,n,s,w,z:inblge;
a:arrang[a..5,1..3]; of integer;
begin
readln(n);
for i=1 to n do begin
a[a+1,1]:=a[h,1];
a[h+2,2]:=a[h,2];
a[h+3,3]:=a[h,3];
end:
end:
begin
readln(n);
for i:=1 to n do
begin
readln(y,s,w);
z:=y+s+w;
for j:=i to 5 do
begin
if a[j,i] -
02009-08-28 11:30:00@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0mstype
node=record
s:longint;// Score
c:longint;// Chinese
n:longint;// Number
end;
var
a:array[0..1000] of node;
i,j,k,m,sum:longint;
begin
readln(sum);
for i:=1 to sum do
begin
readln(j,k,m);
a[i].n:=i;
a[i].s:=j+k+m;
a[i].c:=j;
end;
for i:=1 to sum-1 do
for j:=sum downto i+1 do
if (a[j].s>a[j-1].s) or ((a[j].s=a[j-1].s) and (a[j].c>a[j-1].c)) then
begin
a[0]:=a[j];
a[j]:=a[j-1];
a[j-1]:=a[0];
end;
for i:=1 to 5 do
writeln(a[i].n,' ',a[i].s);
end.Flag Accepted
题号 P1398
类型(?) 其它
通过 2244人
提交 4812次
通过率 47%
难度 1提交 讨论 题解
-
02009-08-25 23:03:00@
一次AC
program noip_jiangxuejin;
type
re = record
num : integer;
chinese : shortint;
sum : integer;
end;
var
a : array[1..1000] of re;
chn,math,eng,i,j,n,temp : longint;
begin
readln(n);
for i := 1 to n do
begin
read(chn,math,eng);
with a[i] do
begin
num := i;
sum := chn+math+eng;
chinese := chn;
end;
end;
for i := 1 to n-1 do
begin
for j := i+1 to n do
begin
if a[i].sum < a[j].sum then
begin
temp := a[i].sum;
a[i].sum := a[j].sum;
a[j].sum := temp;
temp := a[i].num;
a[i].num := a[j].num;
a[j].num := temp;
temp := a[i].chinese;
a[i].chinese := a[j].chinese;
a[j].chinese := temp;
end else
begin
if (a[i].sum=a[j].sum)and(a[i].chinesea[j].num) then
begin
temp := a[i].sum;
a[i].sum := a[j].sum;
a[j].sum := temp;
temp := a[i].num;
a[i].num := a[j].num;
a[j].num := temp;
temp := a[i].chinese;
a[i].chinese := a[j].chinese;
a[j].chinese := temp;
end;
end;
end;
end;
for i := 1 to 5 do
begin
with a[i] do
begin
write(num,' ');
writeln(sum);
end;
end;
end. -
02009-08-24 17:12:47@
program scholar(input,output);
var n,i,a,z1,z2,z3,zf,xh:longint;
jla,jlb,jlc:array [1..5] of longint;
procedure jh(var a,b:longint);
var c:longint;
begin
c:=a;
a:=b;
b:=c;
end;
begin
readln(n);
for i:=1 to n do
begin
readln(z1,z2,z3);
zf:=z1+z2+z3;
xh:=i;
for a:=1 to 5 do
if zf>jla[a]
then begin
jh(zf,jla[a]);
jh(z1,jlb[a]);
jh(xh,jlc[a]);
end
else if zf=jla[a]
then if z1>jlb[a]
then begin
jh(zf,jla[a]);
jh(z1,jlb[a]);
jh(xh,jlc[a]);
end
else if (z1=jlb[a]) and (xh -
02009-08-23 20:18:16@
晕死,这么简单的题目、、、居然以为N
-
02009-08-22 14:12:42@
原汁原味的纯模拟!
#includeusing namespace std;
int nb[1000][1000];
int main()
{memset(nb,0,sizeof(nb));
int n,i,j, a, b, c, total,l,chengji,xu,mm,yy,gg,chi;
cin >> n;
for(i = 1; i > a >> b >> c;
total = a + b + c;
if( total > nb[1][2] )
{
xu = nb[1][1];
chengji = nb[1][2];
chi = nb[1][3];
nb[1][1] = i;
nb[1][2] = total;
nb[1][3] = a;
for(j = 2; j nb[2][2])
{
xu = nb[2][1];
chengji = nb[2][2];
chi = nb[2][3];
nb[2][1] = i;
nb[2][2] = total;
nb[2][3] = a;for(j = 3; j nb[3][2])
{
xu = nb[3][1];
chengji = nb[3][2];
chi = nb[3][3];
nb[3][1] = i;
nb[3][2] = total;
nb[3][3] = a;for(j = 4; j nb[4][2])
{
nb[5][1] = nb[4][1];
nb[5][2] = nb[4][2];
nb[5][3] = nb[4][3];
nb[4][1] = i;
nb[4][2] = total;
nb[4][3] = a;
}
else if(total > nb[5][2])
{
nb[5][1] = i;
nb[5][2] = total;
nb[5][3] = a;
}
}for(int cc = 1; cc nb[cc + 1][1] && nb[cc][3] == nb[cc+1][33])
{
int temp1 = nb[cc][1];
int temp2 = nb[cc][2];
int temp3 = nb[cc][3];
nb[cc][1] = nb[cc+1][1];
nb[cc][2] = nb[cc+1][2];
nb[cc][3] = nb[cc+1][3];
nb[cc+1][1] = temp1;
nb[cc+1][2] = temp2;
nb[cc+1][3] = temp3;
}}
cout -
02009-08-19 15:16:25@
type node=record
hm,yw,sx,wy,zf:longint;
end;
var stu:array[1..1000]of node;
n,i,j,k,t,y,s,w:longint;
begin
readln(n);
for i:=1 to n do
begin
readln(y,s,w);
with stu[i] do
begin
hm:=i;
yw:=y;
sx:=s;
wy:=w;
zf:=y+s+w;
end;
end;
for i:=1 to n-1 do
begin
k:=i;
for j:=i+1 to n do
if (stu[j].zf>stu[k].zf)or((stu[j].zf=stu[k].zf)and(stu[j].yw>stu[k].yw)) then k:=j;
t:=stu[i].zf;stu[i].zf:=stu[k].zf;stu[k].zf:=t;
t:=stu[i].yw;stu[i].yw:=stu[k].yw;stu[k].yw:=t;
t:=stu[i].hm;stu[i].hm:=stu[k].hm;stu[k].hm:=t;
end;
for i:=1 to 5 do
writeln(stu[i].hm,' ',stu[i].zf);
end.
不告诉我n -
02009-08-15 14:13:50@
我到现在都不知道n到底最大是多少,反正数组开的是100000
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms选排就秒杀
-
02009-08-15 13:34:26@
出题的也不至于这样吧
欺负我傻×
n怎么没范围的????!!!!
囧囧rz -
02009-08-13 11:31:49@
闷,第一次用快排居然超时了,第二次用选择排序就ac了……
procedure change(var s1,s2:longint);
var t:longint;
begin
t:=s1; s1:=s2; s2:=t;
end;begin
readln(n);
for i:=1 to n do begin
read(b[i]); read(q); readln(p);
a[i]:=b[i]+p+q; c[i]:=i;
end;
for i:=1 to 5 do begin
for j:=i+1 to n do begin
if a[i] -
02009-08-07 19:44:59@
program p1398;
var zf,yw,xh:array[1..10000] of longint;
n,a,b,c,i:longint;procedure swap(var a,b:longint);
var t:longint;
begin
t:=a;a:=b;b:=t;
end;procedure qs(l,r:longint);
var i,j,x1,x2,x3:longint;
begin
i:=l;j:=r;
x1:=zf[(i+j) div 2];
x2:=yw[(i+j) div 2];
x3:=xh[(i+j) div 2];
repeat
while (zf[i]>x1) or ((zf[i]=x1) and (yw[i]>x2)) or ((zf[i]=x1) and (yw[i]=x2) and (xh[i] -
02009-08-06 20:01:05@
排序
关键是看清题目,判断在哪种情况下可以交换 -
02009-08-05 09:09:57@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
var
n,i,j,k:longint;
a,b,c:array[0..1000] of longint;
begin
readln(n);
for i:=1 to n do
begin
readln(a[i],j,k);
b[i]:=a[i]+j+k;
c[i]:=i;
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if b[i]c[j] then begin
k:=c[i];c[i]:=c[j];c[j]:=k;
end
else
else if a[i] -
02009-08-04 18:05:03@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms有点长,不过格式好。。。。。
=======================晒程序======================
var
a:array[0..1000] of string;
n,i,x,y,z,tmp:longint;
st:string;
function load1(tmp:longint):string;
var
x,st:string;
begin
x:='';
tmp:=999-tmp;
if tmp -
02009-08-04 13:06:04@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0msProgram Scholar;
Var n,i,num,code:integer;
temp:string;
a:array[1..300] of string[9];
cn,ma,en,sum:array[1..300] of integer;
Procedure init;
Var i,j,l:longint;
temp:string;
Begin
readln(n);
for i:=1 to n do
begin
readln(cn[i],ma[i],en[i]);
sum[i]:=cn[i]+ma[i]+en[i];str(sum[i],temp);
l:=length(temp);
for j:=1 to 3-l do a[i]:=a[i]+'0';
a[i]:=a[i]+temp;str(cn[i],temp);
l:=length(temp);
for j:=1 to 3-l do a[i]:=a[i]+'0';
a[i]:=a[i]+temp;str(300-i,temp);
l:=length(temp);
for j:=1 to 3-l do a[i]:=a[i]+'0';
a[i]:=a[i]+temp;
end;
End;
Procedure Sort(s,e:integer);
Var i,j:integer;
t:string[9];
Begin
i:=s; j:=e; t:=a[i];
while i