当前位置:网站首页>结果填空 马虎的算式(暴力解决)
结果填空 马虎的算式(暴力解决)
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;
}
边栏推荐
猜你喜欢

顺序表的增删查改

Using Navicat or PLSQL to export CSV format, more than 15 digits will become 000 (e+19) later

Zotero——一款文献管理工具

Review of metallurgical physical chemistry -- cathodic polarization, overpotential, anode and anode process in metal electrodeposition

顺序表oj之删除特定的元素

Review of metallurgical physical chemistry --- liquid liquid reaction kinetics

shell运行原理

【博学谷学习记录】超强总结,用心分享 | 集合

How Visio can quickly generate the same pattern and image matrix

VMware Workstation is incompatible with device/credential guard. Disable device/credential guard
随机推荐
Writing methods of scientific research papers: add analysis and discussion in the method part to explain their contributions and differences
RESNET structure comparison
JVM notes 3: class loading and bytecode Technology
基于Easy CHM和VS的帮助文档制作
URL form
Arrangement of main drawings of the latest 54 papers of eccv22
Sequence table OJ topic
NRF51822 回顾总结
Docker deploy mysql5.7.35
Mabtis (I) basic use of framework
图片根据屏幕自适应
wangeditor(@4.7.15)-轻量级的富文本编辑器
Review of metallurgical physical chemistry ---- gas solid reaction kinetics
MYSQL之搭建数据库系列(一)——下载MYSQL
openjudge:石头剪刀布
ES6--->箭头函数、类、模块化
DOM基础
C语言推箱子
环形链表问题
ArcMap中的距离工具条(Distance)