337 条题解
-
0
zgx LV 10 @ 2009-02-05 21:23:06
测试数据怎么大的题也能审核通过???!!!
-
0@ 2009-02-04 15:14:58
修改一下下就行了,同学也是这样做,为什么我偏偏错了?
var i,j,l1,l2,m,g:longint;
s1,s2:ansistring;
a,b:array[0..500] of integer;
begin
readln(s1);
readln(s2);
l1:=length(s1); l2:=length(s2);
for i:=1 to l1 do val(s1[i],a[i],g);
for i:=1 to l2 do val(s2[i],b[i],g);
for i:=1 to l1 do
for j:=1 to 500 do
begin
m:=a[i]*b[j]+g;
a[i]:=m mod 10;
g:=m div 10;
end;
j:=1000;
while a[j]=0 do j:=j-1;
for i:=1 to j do write(a[i]);
end. -
0@ 2009-01-28 18:51:51
原来以为是自己高精度写错了
结果果然是自己高精度写错了
现在竟然还是不知道自己怎么写错的
可是自己的那套写法写了很多题目都没有问题
我只想说……faint -
0@ 2009-01-26 22:24:07
#include
#include
char str1[10001],str2[10001];
long len1,len2,alen,blen,clen;
long a[3340],b[3340],c[6680];
long i,j,k,n,m;
long s,t;
int main(){
gets(str1);gets(str2);
alen=0;
len1=strlen(str1);
for (i=len1-1;i>=0;i=s-1){
s=i-2; t=i;
if (s -
0@ 2009-01-24 18:05:36
水题……囧了……多打了个0……囧了4次0分。
看本人的100000000进制数!
{——————————————————————————————————}编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0msvar
s1,s2:ansistring;
len,l1,l2,i,j:longint;
a,b,c:array[0..20000]of qword;
begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(c,sizeof(c),0);
readln(s1);
readln(s2);
l1:=length(s1);
l2:=length(s2);
for i:=1 to l1 do
begin
j:=(l1-i) div 8+1;
a[j]:=a[j]*10+ord(s1[i])-48;
end;
for i:=1 to l2 do
begin
j:=(l2-i) div 8+1;
b[j]:=b[j]*10+ord(s2[i])-48;
end;
l1:=l1 div 8+1;
l2:=l2 div 8+1;
len:=l1+l2;
for i:=1 to l1 do
for j:=1 to l2 do
c:=a[i]*b[j]+c;
for i:=2 to len do
begin
c[i]:=c[i]+c div 100000000;
c:=c mod 100000000;
end;
while c[len+1]>0 do inc(len);
while c[len]=0 do dec(len);
write(c[len]);
for i:=len-1 downto 1 do
write(c[i] div 10000000,
(c[i] div 1000000) mod 10,
(c[i] div 100000) mod 10,
(c[i] div 10000) mod 10,
(c[i] div 1000) mod 10,
(c[i] div 100) mod 10,
(c[i] div 10) mod 10,
c[i] mod 10);
end.Flag Accepted
题号 P1040
类型(?) 数论 / 数值
通过 2236人
提交 13959次
通过率 16%
难度 3提交 讨论 题解
-
0@ 2009-01-17 10:56:55
做完这题我好恶心……
-
0@ 2008-12-21 14:15:57
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案错误...
├ Hint: WA ├ 标准行输出
├ 错误行输出
---|---|---|---|---|---|---|---|-program xaq;
type
atype=array[0..100000]of integer;
var
a,b,c:atype;
s:ansistring;
len1,len2,i,j,k:integer;
begin
readln(s);
len1:=length(s);
for i:=0 to len1-1 do
a[len1-i-1]:=ord(s)-48;
readln(s);
len2:=length(s);
for i:=0 to len2-1 do
b[len2-i-1]:=ord(s)-48;
for i:=len1-1 downto 0 do
begin
for j:=len2-1 downto 0 do
c:=c+a[i]*b[j];
end;
k:=len1+len2-1;
for i:=0 to k-1 do
begin
c:=c+c[i]div 10;
c[i]:=c[i] mod 10;
end;
if c[k]0 then k:=k+1;
for i:=k-1 downto 0 do write(c[i]);
end.哪里错了?????????????????????????????????
-
0@ 2008-12-21 13:47:18
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0msWa了怎么多次,原来因为ansistring......
-
0@ 2008-12-19 21:28:01
R1100041 Accepted 100 From sza603-
P1040 GCC Vag 6K 2008-12-19 20:57:28编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 9ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:9ms#include
#include
typedef long NUM[1112],RES[2223];void cvtnum(const char*n,NUM num,int*len) {
int i,l;
const long _10n[]={1,10,100,1000,10000,100000,1000000,10000000,100000000};
for(l=strlen(n),i=0;i=0) printf("%09ld",n);
}int main() {
char s[10001];
NUM a={0},b={0};
RES c={0};
int ca,cb;
cvtnum(gets(s),a,&ca),cvtnum(gets(s),b,&cb);
mul(a,b,ca,cb,c);
out(c);
return 0;
}1000000000进制………………
-
0@ 2008-12-14 21:51:17
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 41ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:41ms编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 9ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:9ms同样的代码GCC用了41ms,CPP竟然只用了9ms,真是郁闷
-
0@ 2008-12-12 23:33:17
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 368ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:368ms无语了……万进制 交 了 2次 才过…… 第一次 最后 一 点 竟然超时……
-
0@ 2008-12-07 14:53:04
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0msprogram p1040;
var
a,b,c:array[1..100000]of longint;
s:ansistring;
i,j,x,la,lb,lc:longint;
begin
readln(s);
la:=length(s);
for i:=1 to la do
a[la-i+1]:=ord(s[i])-48;
readln(s);
lb:=length(s);
for i:=1 to lb do
b[lb-i+1]:=ord(s[i])-48;
fillchar(c,sizeof(c),0);
for i:=1 to la do
begin
x:=0;
for j:=1 to lb do
begin
x:=a[i]*b[j]+x div 10+c;
c:=x mod 10;
end;
c:=x div 10;
end;
lc:=la+lb;
while (c[lc]=0)and(lc>1) do
dec(lc);
for i:=lc downto 1 do write(c[i]);
end. -
0@ 2008-12-05 19:08:03
var s1,s2:ansistring;
n,i,j,l1,l2,x,p:longint;
a,b,c:array[0..10000]of longint;
begin
readln(s1);
readln(s2);
if length(s1) mod 4=0 then l1:=length(s1) div 4 else l1:=length(s1) div 4+1;
if length(s1) mod 4=0 then p:=1 else p:=2;
for i:=l1+1-length(s1) div 4 to l1 do
for j:=1 to 4 do
a[i]:=a[i]*10+ord(s1[(i-p)*4+length(s1) mod 4+j])-48;
for i:=1 to length(s1) mod 4 do a[1]:=a[1]*10+ord(s1[i])-48;
n:=length(s2);
if n mod 4=0 then l2:=n div 4 else l2:=n div 4+1;
if n mod 4=0 then p:=1 else p:=2;
for i:=l2+1-n div 4 to l2 do
for j:=1 to 4 do
b[i]:=b[i]*10+ord(s2[(i-p)*4+n mod 4+j])-48;
for i:=1 to n mod 4 do b[1]:=b[1]*10+ord(s2[i])-48;
for i:=l1 downto 1 do
for j:=l2 downto 1 do
begin
c:=c+a[i]*b[j];
c:=c+cdiv 10000;
c:=c mod 10000;
end;
x:=0;
while c[x]=0 do inc(x);
write(c[x]);
for i:=x+1 to l1+l2-1 do
if c[i] -
0@ 2008-12-13 09:37:16
var st1,st2:string;
a,b,c:array[1..500] of integer;
ln1,ln2,i,j,max,s:integer;
begin
readln(st1);
readln(st2);
ln1:=length(st1);
ln2:=length(st2);
for i:=1 to ln1 do a[ln1-i+1]:=ord(st1[i])-48;
for i:=1 to ln2 do b[ln2-i+1]:=ord(st2[i])-48;
for i:=1 to ln1 do
for j:=1 to ln2 do
begin
s:=i+j-1;
c:=a[i]*b[j]+c;
if c>=10 then
begin
c:=c+c div 10;
c:=c mod 10;
end;
end;
max:=ln1+ln2;
while (c[max]=0) and (max>1) do
max:=max-1;
for i:=max downto 1 do
begin
write(c[i]);
end;
writeln;
end.哪位大牛帮我看一下,我是小学的,也想找师傅
-
0@ 2008-11-25 21:57:34
无法忍受此题。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
-
0@ 2008-11-21 22:03:58
丑陋的代码
var s1,s2:ansistring;
n,i,j,l1,l2,x,p:longint;
a,b,c:array[0..10000]of longint;
begin
readln(s1);
readln(s2);
n:=length(s1);
if n mod 4=0 then l1:=n div 4 else l1:=n div 4+1;
if n mod 4=0 then p:=1 else p:=2;
for i:=l1+1-n div 4 to l1 do
for j:=1 to 4 do
a[i]:=a[i]*10+ord(s1[(i-p)*4+n mod 4+j])-48;
for i:=1 to n mod 4 do a[1]:=a[1]*10+ord(s1[i])-48;
n:=length(s2);
if n mod 4=0 then l2:=n div 4 else l2:=n div 4+1;
if n mod 4=0 then p:=1 else p:=2;
for i:=l2+1-n div 4 to l2 do
for j:=1 to 4 do
b[i]:=b[i]*10+ord(s2[(i-p)*4+n mod 4+j])-48;
for i:=1 to n mod 4 do b[1]:=b[1]*10+ord(s2[i])-48;
for i:=l1 downto 1 do
for j:=l2 downto 1 do
begin
c:=c+a[i]*b[j];
c:=c+cdiv 10000;
c:=c mod 10000;
end;
x:=0;
while c[x]=0 do inc(x);
write(c[x]);
for i:=x+1 to l1+l2-1 do
if c[i] -
0@ 2008-11-13 22:05:20
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 9ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:9ms#include
#include
main ()
{
char a1[10005],b1[10005];
int a[10005],b[10005],c[20015]={0};
scanf ("%s%s",a1,b1);
int as=strlen (a1),bs=strlen (b1);
int cs,t=0,t1=0;
for (int i=as-4;i>=0;i-=4)
a[t++]=(a1[i]-'0')*1000+(a1-'0')*100+(a1-'0')*10+(a1-'0')*1;
if (as-t*4==3)
a[t]=(a1[0]-'0')*100+(a1[1]-'0')*10+(a1[2]-'0')*1;
else if (as-t*4==2)
a[t]=(a1[0]-'0')*10+(a1[1]-'0')*1;
else if (as-t*4==1)
a[t]=(a1[0]-'0');
for (int i=bs-4;i>=0;i-=4)
b[t1++]=(b1[i]-'0')*1000+(b1-'0')*100+(b1-'0')*10+(b1-'0')*1;
if (bs-t1*4==3)
b[t]=(b1[0]-'0')*100+(b1[1]-'0')*10+(b1[2]-'0')*1;
else if (bs-t1*4==2)
b[t]=(b1[0]-'0')*10+(b1[1]-'0')*1;
else if (bs-t1*4==1)
b[t]=(b1[0]-'0');
for (int i=0;i=0;i--,t1++)
if (b1[i]!='0')
break;
for (int i=cs;i>=0;i--)
{
if (i==cs)
printf ("%d",c[i]);
else printf ("%.4d",c[i]);
}
}
//好像有些慢,不知用百,千进制能不能过,反正万进制肯定过 -
0@ 2008-11-12 21:41:07
这是小菜在NOIP2008之前写的最后一道高精度的题
终于会用位压缩了
第一次交了bak的内容,直接顶歇
我的RP啊! -
0@ 2008-11-12 21:01:24
不怪,虽然学pascal好长时间,不过万进制的高精度 = =
今天还是第一次写。。
囧去了…… -
0@ 2008-11-11 23:26:05
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 72ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:72ms万进制...
program jy;
type
numtype=array[0..10000] of longint;
var
a,b,c:numtype;
as1,as2,ans:ansistring;function mul(a,b:numtype):numtype;
var
t:numtype;
i,x,j,p:longint;
begin
fillchar(t,sizeof(t),0);
for i:=1 to b[0] do
begin
x:=b[i];
for j:=1 to a[0] do
begin
t:=t+a[j]*x;
p:=i+j-1;
while t[p]>=10000 do
begin
t[p+1]:=t[p+1]+t[p] div 10000;
t[p]:=t[p] mod 10000;
p:=p+1;
end;
end;end;
while (t[p]=0) and (p>1) do p:=p-1;
t[0]:=p;
mul:=t;
end;function numstr(a:numtype):ansistring;
var
i,p:integer;
tst:string;
tast:ansistring;
begin
p:=a[0];
str(a[p],tast);
for i:=p-1 downto 1 do
begin
if a[i] div 1000=0 then tast:=tast+'0';
if a[i] div 100=0 then tast:=tast+'0';
if a[i] div 10=0 then tast:=tast+'0';
str(a[i],tst);
tast:=tast+tst;
end;
numstr:=tast;
end;function strnum(a:ansistring):numtype;
var
s:string;
begin
fillchar(strnum,sizeof(strnum),0);
repeat
s:=copy(a,length(a)-3,4);
strnum[0]:=strnum[0]+1;
val(s,strnum[strnum[0]]);
a:=copy(a,1,length(a)-4);
until a='';
end;begin
readln(as1);
readln(as2);
a:=strnum(as1);
b:=strnum(as2);
c:=mul(a,b);
ans:=numstr(c);
writeln(ans);
end.