题目: | 你的飞碟在这儿! | |
来源: | Usaco1.1.1 | |
题目大意: | 两个字符串(全大写)将其转化成1~26的数字乘积再mod47,相等输出‘GO’,否 则‘STAY’ | |
数据范围: | 每个字符串不超过6个字符 | |
样例: |
COMETQ HVNGAT |
GO |
做题思路: | 别想别的模拟就好,注意乘法初始化1,还有两个字符串不一定一样长 | |
知识点: | 模拟、字符串处理 |
{
ID:Dount Nameless
TASK:ride
LANG:PASCAL
}
var
ch:char;
x1,x2:longint;
begin
assign(input,'ride.in');reset(input);
assign(output,'ride.out');rewrite(output);
x1:=1;x2:=1;
while not eoln do{<管他几个字母统统读入>}
begin
read(ch);
x1:=x1*(ord(ch)-64);
end;
readln;
while not eoln do
begin
read(ch);
x2:=x2*(ord(ch)-64);
end;
readln;
ifx1 mod 47=x2 mod 47 then writeln('GO') else writeln('STAY');{<比较后输出>}
close(input);close(output);
end.
题目来源:
http://ace.delos.com/usacoprob2?a=RexmW8CclSt&S=ride