当前位置:网站首页>结果填空 马虎的算式(暴力解决)
结果填空 马虎的算式(暴力解决)
2022-07-28 05:19:00 【小白鼠零号】
小明是个急性子,上小学的时候经常把老师写在黑板上的题目抄错了。
有一次,老师出的题目是:36 x 495 = ?
他却给抄成了:396 x 45 = ?
但结果却很戏剧性,他的答案竟然是对的!!
因为 36 * 495 = 396 * 45 = 17820
类似这样的巧合情况可能还有很多,比如:27 * 594 = 297 * 54
假设 a b c d e 代表1~9不同的5个数字(注意是各不相同的数字,且不含0)
能满足形如: ab * cde = adb * ce 这样的算式一共有多少种呢?
请你利用计算机的优势寻找所有的可能,并回答不同算式的种类数。
满足乘法交换律的算式计为不同的种类,所以答案肯定是个偶数。
答案
142
解题过程
说实在的蓝桥杯的选择填空一般暴力解法就能过,只不过它有时会耍小动作(弄个什么精准度什么的,扯远了)。这里直接五重循环暴力解决!
附上代码
#include<iostream>
using namespace std;
int main()
{
int counts=0;
for(int a=1;a<=9;a++)
{
for(int b=1;b<=9;b++)
{
for(int c=1;c<=9;c++)
{
for(int d=1;d<=9;d++)
{
for(int e=1;e<=9;e++)
{
if(a!=b&&a!=c&&a!=d&&a!=e&&b!=c&&b!=d&&b!=e
&&c!=d&&c!=e&&d!=e)
{
int num1=(a*10+b)*(c*100+d*10+e);
int num2=(a*100+d*10+b)*(c*10+e);
if(num1==num2)
counts++;
}
}
}
}
}
}
cout<<counts<<endl;
return 0;
}
边栏推荐
- 树莓派蓝牙调试过程
- Mutual conversion between latex and word
- openjudge:石头剪刀布
- shell运行原理
- DOM基础
- 顺序表oj之合并两个有序数组
- Centos7 install MySQL 5.7
- The essence of dynamic convolution
- Review of metallurgical physical chemistry -- Fundamentals of metallurgical reaction kinetics and characteristics of multiphase reaction kinetics
- Child parent thread interaction
猜你喜欢
随机推荐
pytorch安装----CPU版的
Openjudge: judge whether the string is palindrome
ArcGIS Engine开发资源
Microsoft Edge浏览器插件(2)
基于Easy CHM和VS的帮助文档制作
Arcgis Engine安装的若干问题
蓝桥代码 翻硬币(我这样写也通过了,官网测试是不是有问题)
Use of IO streams
Mysql database index (InnoDB engine)
Zotero——一款文献管理工具
【uni-app】uni-app中scroll-into-view的使用
标准C语言学习总结6
Microsoft Edge浏览器插件(1)
Openjudge: filter extra spaces
顺序表oj之合并两个有序数组
Oracle create table, delete table, modify table (add field, modify field, delete field) statement summary
GD32F407 移植FreeRTOS+Lwip
冶金物理化学复习 --- 复杂反应的速率方程
Review of metallurgical physical chemistry -- Fundamentals of metallurgical reaction kinetics and characteristics of multiphase reaction kinetics
URL form









