当前位置:网站首页>结果填空 马虎的算式(暴力解决)
结果填空 马虎的算式(暴力解决)
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;
}
边栏推荐
- 图片根据屏幕自适应
- 结果填空 国庆有几天是星期日(纯Excel解决)
- 标准C语言学习总结7
- new,let,var,const以及暂时性死区,xml和json的区别
- 冶金物理化学复习 ---- 气固反应动力学
- Collection of architectural design considerations
- Review of metallurgical physical chemistry -- Fundamentals of metallurgical reaction kinetics and characteristics of multiphase reaction kinetics
- ArcGIS Engine开发资源
- DOM——页面的渲染、style属性操作、预加载与懒加载、防抖与节流
- C语言走迷宫
猜你喜欢
![[idea plug-in artifact] teaches you how to set all attributes in an entity class with one click of idea](/img/d6/4e69480c5ad5040ee48941ca0fcb37.png)
[idea plug-in artifact] teaches you how to set all attributes in an entity class with one click of idea

GIS领域竞赛整理(不完全统计)

JUC notes

顺序表oj之合并两个有序数组

ArcGIS之Model Builder

Idea configures the service (run dashboard) service, and multiple modules are started at the same time

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

curd组件中的时间设置

对极大似然估计、梯度下降、线性回归、逻辑回归的理解

How Visio accurately controls the size, position and angle of graphics
随机推荐
DOM--事件链、事件冒泡和捕获、事件代理
三大缓存技术--localStorage、sessionStorage、Cookie
环形链表问题
顺序表oj题目
基于Easy CHM和VS的帮助文档制作
标准C语言总结2
Fusiongan code learning (I)
es6新增--->对象(Object)
JS字符串方法大全
Openjudge: matrix multiplication
ArcGIS之Model Builder
操作文档树
softmax多分类 梯度推导
Solve the problem that Oracle cannot use more than 1000 in statements
C语言回顾(可变参数篇)
Leetcode 随即链表的深拷贝
顺序表的增删查改
【博学谷学习记录】超强总结,用心分享 | 集合
C语言通讯录系统
DOM操作的案例