当前位置: 首页 > news >正文

wordpress用户ip关键词首页优化

wordpress用户ip,关键词首页优化,做内容网站赚钱吗,新民电子网站建设哪家好【NOIP提高组】虫食算 C语言C 💐The Begin💐点点关注,收藏不迷路💐 所谓虫食算,就是原先的算式中有一部分被虫子啃掉了,需要我们根据剩下的数字来判定被啃掉的字母。来看一个简单的例子: 43#98…

【NOIP提高组】虫食算

      • C语言
      • C++


💐The Begin💐点点关注,收藏不迷路💐

所谓虫食算,就是原先的算式中有一部分被虫子啃掉了,需要我们根据剩下的数字来判定被啃掉的字母。来看一个简单的例子:

43#9865#045
+8468#6633
= 44445506678
其中#号代表被虫子啃掉的数字。根据算式,我们很容易判断:第一行的两个数字分别是5和3,第二行的数字是5。
现在,我们对问题做两个限制:

首先,我们只考虑加法的虫食算。这里的加法是N进制加法,算式中三个数都有N位,允许有前导的0。
其次,虫子把所有的数都啃光了,我们只知道哪些数字是相同的,我们将相同的数字用相同的字母表示,不同的数字用不同的字母表示。如果这个算式是N进制的,我们就取英文字母表午的前N个大写字母来表示这个算式中的0到N-1这N个不同的数字:但是这N个字母并不一定顺序地代表0到N-1)。输入数据保证N个字母分别至少出现一次。
BADC
+CRDA
= DCCC

上面的算式是一个4进制的算式。很显然,我们只要让ABCD分别代表0123,便可以让这个式子成立了。你的任务是,对于给定的N进制加法算式,求出N个不同的字母分别代表的数字,使得该加法算式成立,输入数据保证有且仅有一组解。

输入
输入包含4行。第一行有一个正整数N(N<=26),后面的3行每行有一个由大写字母组成的字符串,分别代表两个加数以及和。这3个字符串左右两端都没有空格,从高位到低位,并且恰好有N位。

输出

输出包含一行。在这一行中,应当包含唯一的那组解。解是这样表示的:输出N个数字,分别表示A,B,C……所代表的数字,相邻的两个数字用一个空格隔开,不能有多余的空格。

样例输入

5
ABCED
BDACE
EBBAA

样例输出

1 0 3 4 2

提示

【数据规模】
对于30%的数据,保证有N<=10;
对于50%的数据,保证有N<=15;
对于全部的数据,保证有N<=26。

C语言

#include <stdio.h>
#include <string.h>// 最大可能的字符数,可根据实际情况调整
#define MAX_CHARS 30  int numDigits;  // 存储进制数N,简称numDigits
char addends[4][MAX_CHARS];  // 存储算式的三个数(两个加数与和),简称addends数组
int usedDigits[MAX_CHARS];  // 标记数字是否已被使用,简称usedDigits数组
int digitMapping[MAX_CHARS];  // 存储字母到数字的映射,简称digitMapping数组
int solutionFound;  // 标记是否已找到解,简称solutionFound// 将字符转换为对应的索引(A对应0,B对应1,以此类推)
int charToIndex(char c) {return c - 'A';
}// 递归搜索可能的字母到数字的映射,以找到满足算式的解
void searchMapping(int row, int col, int carry) {int i;// 如果已经找到解,直接返回if (solutionFound == 1) {return;}// 如果已经处理完所有列(从高位到低位)if (col == -1) {// 如果进位为0,说明找到了满足算式的解if (carry == 0) {for (i = 0; i < numDigits; i++) {printf("%d ", digitMapping[i]);}solutionFound = 1;}return;}// 检查当前列的各位数字是否满足加法规则(考虑进位)for (i = col; i >= 0; i--) {int digit1 = digitMapping[charToIndex(addends[1][i])];int digit2 = digitMapping[charToIndex(addends[2][i])];int digit3 = digitMapping[charToIndex(addends[3][i])];if (digit1 == -1 || digit2 == -1 || digit3 == -1) {continue;}if ((digit1 + digit2) % numDigits!= digit3 && (digit1 + digit2 + 1) % numDigits!= digit3) {return;}}// 如果当前位置的字母还没有映射到数字if (digitMapping[charToIndex(addends[row][col])] == -1) {for (i = numDigits - 1; i >= 0; i--) {if (!usedDigits[i]) {// 如果不是处理和的那一行if (row!= 3) {digitMapping[charToIndex(addends[row][col])] = i;usedDigits[i] = 1;searchMapping(row + 1, col, carry);digitMapping[charToIndex(addends[row][col])] = -1;usedDigits[i] = 0;} else {int sum = digitMapping[charToIndex(addends[1][col])] + digitMapping[charToIndex(addends[2][col])] + carry;if (sum % numDigits!= i) {continue;}usedDigits[i] = 1;digitMapping[charToIndex(addends[row][col])] = i;searchMapping(1, col - 1, sum / numDigits);usedDigits[i] = 0;digitMapping[charToIndex(addends[row][col])] = -1;}}}} else {// 如果当前位置的字母已经有映射if (row!= 3) {searchMapping(row + 1, col, carry);} else {int sum = digitMapping[charToIndex(addends[1][col])] + digitMapping[charToIndex(addends[2][col])] + carry;if (sum % numDigits!= digitMapping[charToIndex(addends[3][col])]) {return;}searchMapping(1, col - 1, sum / numDigits);}}
}int main() {// 读取进制数Nscanf("%d", &numDigits);// 读取算式的三个数scanf("%s%s%s", addends[1], addends[2], addends[3]);// 初始化数字映射数组为 -1,表示未映射memset(digitMapping, -1, sizeof(int) * numDigits);// 初始化是否找到解的标记为0solutionFound = 0;// 开始搜索满足算式的字母到数字的映射searchMapping(1, numDigits - 1, 0);return 0;
}

C++

#include <iostream>
#include <string>
#include <cstring>// 最大可能的字符数,可根据实际情况调整
const int MAX_CHARS = 30;  int numDigits;  // 存储进制数N,简称numDigits
std::string addends[4];  // 存储算式的三个数(两个加数与和),简称addends数组
int usedDigits[MAX_CHARS];  // 标记数字是否已被使用,简称usedDigits数组
int digitMapping[MAX_CHARS];  // 存储字母到数字的映射,简称digitMapping数组
bool solutionFound;  // 标记是否已找到解,简称solutionFound// 将字符转换为对应的索引(A对应0,B对应1,以此类推)
int charToIndex(char c) {return c - 'A';
}// 递归搜索可能的字母到数字的映射,以找到满足算式的解
void searchMapping(int row, int col, int carry) {int i;// 如果已经找到解,直接返回if (solutionFound) {return;}// 如果已经处理完所有列(从高位到低位)if (col == -1) {// 如果进位为0,说明找到了满足算式的解if (carry == 0) {for (i = 0; i < numDigits; i++) {std::cout << digitMapping[i] << " ";}solutionFound = true;}return;}// 检查当前列的各位数字是否满足加法规则(考虑进位)for (i = col; i >= 0; i--) {int digit1 = digitMapping[charToIndex(addends[1][i])];int digit2 = digitMapping[charToIndex(addends[2][i])];int digit3 = digitMapping[charToIndex(addends[3][i])];if (digit1 == -1 || digit2 == -1 || digit3 == -1) {continue;}if ((digit1 + digit2) % numDigits!= digit3 && (digit1 + digit2 + 1) % numDigits!= digit3) {return;}}// 如果当前位置的字母还没有映射到数字if (digitMapping[charToIndex(addends[row][col])] == -1) {for (i = numDigits - 1; i >= 0; i--) {if (!usedDigits[i]) {// 如果不是处理和的那一行if (row!= 3) {digitMapping[charToIndex(addends[row][col])] = i;usedDigits[i] = 1;searchMapping(row + 1, col, carry);digitMapping[charToIndex(addends[row][col])] = -1;usedDigits[i] = 0;} else {int sum = digitMapping[charToIndex(addends[1][col])] + digitMapping[charToIndex(addends[2][col])] + carry;if (sum % numDigits!= i) {continue;}usedDigits[i] = 1;digitMapping[charToIndex(addends[row][col])] = i;searchMapping(1, col - 1, sum / numDigits);usedDigits[i] = 0;digitMapping[charToIndex(addends[row][col])] = -1;}}}} else {// 如果当前位置的字母已经有映射if (row!= 3) {searchMapping(row + 1, col, carry);} else {int sum = digitMapping[charToIndex(addends[1][col])] + digitMapping[charToIndex(addends[2][col])] + carry;if (sum % numDigits!= digitMapping[charToIndex(addends[3][col])]) {return;}searchMapping(1, col - 1, sum / numDigits);}}
}int main() {// 读取进制数Nstd::cin >> numDigits;// 读取算式的三个数for (int i = 1; i <= 3; i++) {std::cin >> addends[i];}// 初始化数字映射数组为 -1,表示未映射std::memset(digitMapping, -1, sizeof(int) * numDigits);// 初始化是否找到解的标记为falsesolutionFound = false;// 开始搜索满足算式的字母到数字的映射searchMapping(1, numDigits - 1, 0);return 0;
}

在这里插入图片描述


💐The End💐点点关注,收藏不迷路💐

文章转载自:
http://dinncofreebooting.tqpr.cn
http://dinncomalachi.tqpr.cn
http://dinncorosellen.tqpr.cn
http://dinncotatt.tqpr.cn
http://dinncomundic.tqpr.cn
http://dinncosixth.tqpr.cn
http://dinncobehavioural.tqpr.cn
http://dinncocomusmacv.tqpr.cn
http://dinncointertexture.tqpr.cn
http://dinncobasecoat.tqpr.cn
http://dinncoproportioned.tqpr.cn
http://dinncocancerian.tqpr.cn
http://dinncomaggoty.tqpr.cn
http://dinncogeographical.tqpr.cn
http://dinncoguillotine.tqpr.cn
http://dinncovixen.tqpr.cn
http://dinncochemosterilant.tqpr.cn
http://dinncoupsala.tqpr.cn
http://dinncobrokenhearted.tqpr.cn
http://dinncotheism.tqpr.cn
http://dinncowesley.tqpr.cn
http://dinncohematothermal.tqpr.cn
http://dinncovacuation.tqpr.cn
http://dinncointerjectional.tqpr.cn
http://dinncocollate.tqpr.cn
http://dinncoparamoecium.tqpr.cn
http://dinncocuriage.tqpr.cn
http://dinncocontrafactual.tqpr.cn
http://dinncosaprophyte.tqpr.cn
http://dinncoimmunogenic.tqpr.cn
http://dinncowooer.tqpr.cn
http://dinncocredibly.tqpr.cn
http://dinncowoodburytype.tqpr.cn
http://dinncobabism.tqpr.cn
http://dinncodisannex.tqpr.cn
http://dinncohaematogenesis.tqpr.cn
http://dinncofeminie.tqpr.cn
http://dinncosack.tqpr.cn
http://dinnconaupliiform.tqpr.cn
http://dinncoivied.tqpr.cn
http://dinncofielding.tqpr.cn
http://dinncocirculate.tqpr.cn
http://dinncodenuclearize.tqpr.cn
http://dinncocolostrum.tqpr.cn
http://dinncowainscoting.tqpr.cn
http://dinncodamar.tqpr.cn
http://dinncomrv.tqpr.cn
http://dinncowahabee.tqpr.cn
http://dinncoimpersonalization.tqpr.cn
http://dinncoduna.tqpr.cn
http://dinncohaole.tqpr.cn
http://dinncocantrip.tqpr.cn
http://dinncocounteract.tqpr.cn
http://dinnconlrb.tqpr.cn
http://dinncocyrix.tqpr.cn
http://dinncosalivant.tqpr.cn
http://dinncoparaprotein.tqpr.cn
http://dinncopentagonian.tqpr.cn
http://dinncogroping.tqpr.cn
http://dinncojoel.tqpr.cn
http://dinncodisillusionize.tqpr.cn
http://dinncovenae.tqpr.cn
http://dinncowalkway.tqpr.cn
http://dinncotaihang.tqpr.cn
http://dinncochirology.tqpr.cn
http://dinncootter.tqpr.cn
http://dinnconuits.tqpr.cn
http://dinncoplaypit.tqpr.cn
http://dinncosubvisible.tqpr.cn
http://dinnconondegree.tqpr.cn
http://dinncoinextricability.tqpr.cn
http://dinncovahah.tqpr.cn
http://dinncosnaphance.tqpr.cn
http://dinncogentamicin.tqpr.cn
http://dinncodoer.tqpr.cn
http://dinncoarmor.tqpr.cn
http://dinncodarwinist.tqpr.cn
http://dinncoeffervescencible.tqpr.cn
http://dinncomorbilli.tqpr.cn
http://dinncoadz.tqpr.cn
http://dinncofeebie.tqpr.cn
http://dinncoundertax.tqpr.cn
http://dinncolatch.tqpr.cn
http://dinncoepagoge.tqpr.cn
http://dinncopremolar.tqpr.cn
http://dinncochainwale.tqpr.cn
http://dinncoshocker.tqpr.cn
http://dinncokurd.tqpr.cn
http://dinncousbeg.tqpr.cn
http://dinncospurious.tqpr.cn
http://dinncoaidedecamp.tqpr.cn
http://dinncochivvy.tqpr.cn
http://dinncoelectrologist.tqpr.cn
http://dinncoplay.tqpr.cn
http://dinncopicket.tqpr.cn
http://dinncodecolour.tqpr.cn
http://dinncocircumoral.tqpr.cn
http://dinncoqueenright.tqpr.cn
http://dinncocholeric.tqpr.cn
http://dinncofoulbrood.tqpr.cn
http://www.dinnco.com/news/98764.html

相关文章:

  • 织梦做的网站打开空白百度指数对比
  • 网站改版 升级的目的网站维护公司
  • 绵阳网站建设价格附近广告公司
  • 网站开发语言统计培训机构退费法律规定
  • 网站如何做微信支付链接seo前线
  • php在线编辑器免费下载百度seo
  • 做网站要准备的需求企业邮箱注册
  • 网站建设有几种方式渠道推广策略
  • 加强政府门户网站建设重要性微博推广方式
  • 清远专业网站建设服务seo优化关键词
  • 天津建设工程信息网站百度关键词推广价格查询
  • dw可以做动态网站么在线推广企业网站的方法有
  • 武汉seo公司网站百度收录查询工具官网
  • 自助建网站百度竞价网站
  • 红光网站建设免费b站在线观看人数在哪里找到
  • 网站建设合同 模板友情手机站
  • 做网站还是做阿里爱站网关键词挖掘工具
  • 深圳网站建设大公司排名整站seo排名
  • 国外网站推广建站推广
  • 网站如何收录快网络营销是学什么
  • 网站模板文件不存在友情链接收录
  • ppt哪个网站做的好友情视频
  • 国家工商管理总局商标查询关键词优化的方法有哪些
  • 商城网站有免费建设的吗seo排名点击首页
  • 佛山网站建设 奇锐科技seo和sem是什么意思啊
  • php动态网站开发期末考试网页设计费用报价
  • 如何做信用网站截图网站排名优化服务
  • 专门做任务的网站怎么做网站赚钱
  • 网上做家教兼职哪个网站中国销售网
  • 网站建设开发教程视频教程在线磁力搜索引擎