如果发现广告等破坏行为,请尽量将条目恢复到较早的版本而不是把相应内容直接删除,谢谢合作。
Talk:USACO/ride/中文翻译
来自"NOCOW"
var
s,t,w:string;
i,j,m,n,l,k,z:longint;
procedure make(w:string);
begin
if w='A' then
l:=l*1;
if w='B' then
l:=l*2;
if w='C' then
l:=l*3;
if w='D' then
l:=l*4;
if w='E' then
l:=l*5;
if w='F' then
l:=l*6;
if w='G' then
l:=l*7;
if w='H' then
l:=l*8;
if w='I' then
l:=l*9;
if w='J' then
l:=l*10;
if w='K' then
l:=l*11;
if w='L' then
l:=l*12;
if w='M' then
l:=l*13;
if w='N' then
l:=l*14;
if w='O' then
l:=l*15;
if w='P' then
l:=l*16;
if w='Q' then
l:=l*17;
if w='R' then
l:=l*18;
if w='S' then
l:=l*19;
if w='T' then
l:=l*20;
if w='U' then
l:=l*21;
if w='V' then
l:=l*22;
if w='W' then
l:=l*23;
if w='X' then
l:=l*24;
if w='Y' then
l:=l*25;
if w='Z' then
l:=l*26;
end;
begin
assign(input,'ride.in');reset(input);
assign(output,'ride.out');rewrite(output);
readln(s);
readln(t);
m:=length(s);
n:=length(t);
l:=0;
for i:=1 to m do
make(s[i]);
k:=l mod 47;
l:=0;
for i:=1 to n do
make(t[i]);
z:=l mod 47;
if k=z then
writeln('GO')
else
writeln('STAR');
close(input);
close(output);
end.
[编辑] 不用那么麻烦
program ride; var
i,s1,s2:longint; a,b:array [1..7] of longint; ch:char;
begin
assign(input,'ride.in');reset(input);
assign(output,'ride.out');rewrite(output);
fillchar(a,sizeof(a),0);fillchar(b,sizeof(b),0);
i:=1;
s1:=1;
while not(eoln) do
begin
read(ch);
a[i]:=ord(ch)-ord('A')+1;
if (s1*a[i]) mod 47<>0 then s1:=(s1*a[i]) mod 47
else s1:=s1*a[i];
inc(i);
end;
readln;
i:=1;s2:=1;
while not(eoln) do
begin
read(ch);
b[i]:=ord(ch)-ord('A')+1;
if (s2*a[i]) mod 47<>0 then s2:=(s2*a[i]) mod 47
else s2:=s2*a[i];
inc(i);
end;
if s1=s2 then writeln('GO')
else writeln('STAY');
close(input);close(output);
end.
- include<stdio.h>
- include<string.h>
main()
{
FILE *in=fopen("ride.in","r"),*out=fopen("ride.out","w");
char c[10];
int t=1,l,i,q=1;
fscanf(in,"%s",c);
l=strlen(c);
for(i=0;i<=l;i++)
{
t*=(c[i]-'A'+1);
t%=47;
}
fscanf(in,"%s",c);
l=strlen(c);
for(i=0;i<=l;i++)
{
q*=(c[i]-'A'+1);
q%=47;
}
if(q==t)
fprintf(out,"GO\n");
else
fprintf(out,"STAY\n");
fclose(in);
fclose(out);
return 0;
}
//听老师说USACO输出要加一个回车,不知道真的假的

