【字符串】Your Ride Is Here

这题真的是很实在的水题啊,解题的关键在于‘ up to 6 characters long.’本来以为串会很长啊或者还要高精度什么的,打开计算器确认过眼神,26^6只有9位数。果断水过。

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
const int maxn = 6 + 2;
const int Mod = 47;
char s1[maxn], s2[maxn];
int m1, m2, len1, len2;
int a[maxn], b[maxn];

void init()
{
	memset(s1, 0, sizeof(s1));
	memset(s2, 0, sizeof(s2));

	scanf("%s%s", s1, s2);
}

void trans()
{
	len1 = strlen(s1); len2 = strlen(s2);
	for(int i = 0; i < len1; i++)
		a[i] = s1[i] - 'A' + 1;
	for(int i = 0; i < len2; i++)
		b[i] = s2[i] - 'A' + 1;
}

void calcu()
{
	m1 = m2 = 1;
	for(int i = 0; i < len1; i++)
		m1 *= a[i];
	for(int i = 0; i < len2; i++)
		m2 *= b[i];
	if(m1 % 47 == m2 % 47)	printf("GO\n");
	else	printf("STAY\n");
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	init();
	trans();
	calcu();
	return 0;
}

 

本来以为很复杂所以取名了很多函数。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值