当前位置:网站首页>洛谷P1200 你的飞碟在这儿Your Ride Is Here
洛谷P1200 你的飞碟在这儿Your Ride Is Here
2022-08-07 04:53:00 【CLH_W】
题目描述
众所周知,在每一个彗星后都有一只 UFO。这些 UFO 时常来收集地球上的忠诚支持者。不幸的是,他们的飞碟每次出行都只能带上一组支持者。因此,他们要用一种聪明的方案让这些小组提前知道谁会被彗星带走。他们为每个彗星起了一个名字,通过这些名字来决定这个小组是不是被带走的那个特定的小组(你认为是谁给这些彗星取的名字呢?)。关于如何搭配的细节会在下面告诉你;你的任务是写一个程序,通过小组名和彗星名来决定这个小组是否能被那颗彗星后面的 UFO 带走。
小组名和彗星名都以下列方式转换成一个数字:最终的数字就是名字中所有字母的积,其中 \texttt AA 是 11,\textttZ 是 2626。例如,\texttt{USACO}USACO 小组就是 21 \times 19 \times 1 \times 3 \times 15=1795521×19×1×3×15=17955。如果小组的数字 \bmod 47mod47 等于彗星的数字 \bmod 47mod47,你就得告诉这个小组需要准备好被带走!(记住“a \bmod bamodb”是 aa 除以 bb 的余数,例如 34 \bmod 1034mod10 等于 44)
写出一个程序,读入彗星名和小组名并算出用上面的方案能否将两个名字搭配起来,如果能搭配,就输出 GO,否则输出 STAY。小组名和彗星名均是没有空格或标点的一串大写字母(不超过 66 个字母)。
输入格式
第1行:一个长度为 11 到 66 的大写字母串,表示彗星的名字。
第2行:一个长度为 11 到 66 的大写字母串,表示队伍的名字。
输出格式
无
输入输出样例
输入 #1复制
COMETQ
HVNGAT
输出 #1复制
GO
输入 #2复制
ABSTAR
USACO
输出 #2复制
STAY
说明/提示
题目翻译来自 NOCOW。
USACO Training Section 1.1
上代码:
#include <stdio.h>
#include <string.h>
int main()
{
char a[3000],s[3000];
int a1,s1,a2=1,s2=1;
int i;
scanf("%s%s",a,s);
a1=strlen(a);//测字符串a长度
s1=strlen(s);//测字符串s长度
for(i=0;i<a1;i++) a2*=a[i]-'A'+1;//转换成数字
for(i=0;i<s1;i++) s2*=s[i]-'A'+1;//转换成数字
if(a2%47==s2%47)
printf("GO\n");
else printf("STAY\n");
return 0;
}
边栏推荐
- tiup cluster disable
- happens-before规则与线程单例安全习题
- typescript79-配置文件tsconfig.json文件
- 预约家教老师上门辅导小程序开发制作功能介绍
- Implementing a simple address book in C language
- golang server proxy
- Records about log4j security vulnerabilities and version to replace
- Excel单元格显示数据与实际数据不一致的设置与清除
- 【TypeScript笔记】03 - TS类型声明文件
- tiup cluster enable
猜你喜欢

typescript85-class组件类型

npm install遇到Unexpected end of JSON input while parsing near ‘...onnect“:“^2.0.0“,“gru‘问题解决

2022 Niu Ke Duo School Six J-Number Game (Simple Reasoning)

5 pits that machine learning beginners are easy to step on

课程预约小程序制作功能介绍

Automated operation and maintenance tools - ansible overview and deployment

Brush the title "Sword Finger Offer" day11

2022 Niu Ke Duo School Six B-Eezie and Pie (dfs)

Parse the structure inside the wpf control
![[Shader realizes the overall distortion effect of Distortion_Shader Effect Chapter 17]](/img/c3/6c4cdeed6e1b88e3163541d2ff0eae.png)
[Shader realizes the overall distortion effect of Distortion_Shader Effect Chapter 17]
随机推荐
Some basic concepts and methods of proxy ip (updating...)
课程预约小程序制作功能介绍
聊聊Redis内存优化的7个神技
Tips for recording WPF (2) 16-30
c语言:通讯录
navicat linked server mysql
从简历被拒到收割8个大厂offer,我用了3个月成功破茧成蝶
[LeetCode Daily Question] - 153. Find the minimum value in a rotated sorted array
2022 Niu Ke Duo School Six M-Z-Game on grid (dynamic programming)
position sticky与overflow冲突失效无作用,解决办法
Linear Algebra Study Notes 4-6: Null Space, Column Space, Row Space, Left Null Space, Elementary Row Transformation, Test Questions of Matrix
Fedora Team Announces Fedora 36 System Release
Pytorch中计算自己模型的FLOPs | thop.profile() 方法
多线程之原子整数和原子引用
How to adjust the game settings of Ark Survival Evolved
不是吧,10:00面试,10:08就出来了 ,问的实在是太...
线性代数学习笔记4-4:求解非齐次线性方程组Ax=b,从秩的角度看方程
Go语言 | 05 Template学习
ansible——playbook剧本的讲解与应用
One Pass 1225 - Treasure Island