作业帮 > 综合 > 作业

我的代码是这错了2 个点INPUT112345678901234567890 92 13 24 35 46 57 68

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/07/02 15:02:53
我的代码是
这错了2 个点
INPUT1
12345678901234567890 9
2 1
3 2
4 3
5 4
6 5
7 6
8 7
9 8
0 9
OUTPUT1
13168189440000
INPUT2
65544433332222211111110000000 15
0 1
0 2
0 3
0 4
0 5
0 6
1 2
2 3
3 1
4 5
5 6
6 4
7 8
7 9
1 7
OUTPUT2
20565891225354240000000
const max=50;
type arrtype=array[0..max] of integer;
arrtype2=array[1..2*max] of integer;
var p,i,j,k,l,n,m,x,y,o,g,ss:longint;
a:array[1..100]of integer;
s:string;c1:char;
c:array[-1..10,-1..10]of boolean;
num:arrtype;
function zh(i1:longint):longint;
var j1:longint;
begin
zh:=0;
for j1:=0 to 9 do
if c[i1,j1] then inc(zh);
end;
begin
assign(input,'noipc34.in');reset(input);
assign(output,'noipc3.out');rewrite(output);
i:=0; fillchar(c,sizeof(c),false);
read(c1);
while c1' ' do
begin
inc(i);
a[i]:=ord(c1)-48;
read(c1);
end;
n:=i;
readln(k);
for i:=1 to k do
begin
read (x,y);
c[x,y]:=true;
end;
num[max]:=1;
for i:=0 to 9 do
for j:=1 to 9 do
if i=j then c[i,j]:=true;
for p:=0 to 9 do
for i:=0 to 9 do
for j:=1 to 9 do
c[i,j]:=c[i,j] or(c[i,p]and c[p,j]);
for i:=1 to n do
if zh(a[i])0 then
begin
o:=zh(a[i]);
g:=0;
for j:=max downto 0 do
begin
ss:=num[j]*o+g;
num[j]:=ss mod 10;
g:=ss div 10;
end;
num[0]:=ss;
end;
i:=0;
while num[i]=0 do inc(i);
while i 6
  上面的整数 234 经过变换后可能产生出的整数为(包括原数):
   234
   534
   264
   564
  共 4 种不同的产生数
  给出一个整数 n 和 k 个规则。
求出:
  经过任意次的变换(0次或多次),能产生出多少个不同整数。
  仅要求输出个数。
Input
格式为:
  n k
  x1 y1
  x2 y2
  ......
  xn yn
Output
格式为:
  一个整数(满足条件的个数):
Sample Input
234 2
2 5
3 6
Sample Output
4
我的代码是这错了2 个点INPUT112345678901234567890 92 13 24 35 46 57 68
var f:array[0..1000,0..1000] of boolean;
i,j,kk,k,x,y,num:longint;
ans:int64;
s:string;
begin
readln(s);
val(copy(s,pos(' ',s)+1,length(s)-pos(' ',s)),k);//把k从字符串里分离出来
delete(s,pos(' ',s),length(s)-pos(' ',s)+1);//把s中的k删掉,只保留n
for i:=1 to k do
begin
read(x,y);
f[x,y]:=true;
end;
for i:=0 to 9 do f[i,i]:=true;
for kk:=0 to 9 do
for i:=0 to 9 do
for j:=0 to 9 do
f[i,j]:=(f[i,kk] and f[kk,j])or f[i,j];
ans:=1;
for i:=1 to length(s) do
begin
k:=0;
for j:=0 to 9 do
if f[ord(s[i])-48,j] then k:=k+1;
ans:=ans*k;
while ans mod 10=0 do
begin inc(num);ans:=ans div 10;end;
end;
write(ans);
for i:=1 to num do write(0);
end.
程序发给你,我猜测大概是你输出的数末尾的0没有处理好.
再问: 我用的是高精度啊 该是什么就输出什么呀,能不能具体说一下哪错了,告诉我怎么改 如果我懂了再多给你分 多谢多谢了!