蓝桥杯模拟赛 猜算式
来源:互联网 发布:阿里云服务器租用合同 编辑:程序博客网 时间:2024/06/01 09:53
第一次参加比赛,感觉之前学的好多东西都不知道怎么用,感觉准备很不充分。但是我还是想去拼一下,大不了明年接着刷,保研保本校跟着院长混。
废话不说,直接发出代码。暴力破解,其中代码块复制粘贴了很多,很容易的思路。通俗易懂。
由于我之前做过不少工程项目,我非常不习惯竞赛当中毫无意义的变量,这玩意遇到难题给你代码你都看不懂。非常爆炸。但也是我修为尚浅,继续努力吧。和CSDN诸君共勉。
#include <iostream>using namespace std;int numTimes[10];void Initial(){ for (int i = 0; i < 10; i++) { numTimes[i] = 0; }}bool check(){ for (int i = 0; i < 10; i++) { if (numTimes[i] != 2) { return false; } } return true;}int main(){ Initial(); for (int i = 100; i < 999; i++) { for (int j = 100; j < 999; j++) { int iGewei = i % 10; numTimes[iGewei]++; int iShiwei = (i / 10) % 10; numTimes[iShiwei]++; int iBaiwei = (i / 100); numTimes[iBaiwei]++; int jGewei = j % 10; numTimes[jGewei]++; int jShiwei = (j / 10) % 10; numTimes[jShiwei]++; int jBaiwei = (j / 100); numTimes[jBaiwei]++; int num1 = i*jGewei; if (num1 < 1000) { int num1Gewei = num1 % 10; numTimes[num1Gewei]++; int num1Shiwei = (num1 / 10) % 10; numTimes[num1Shiwei]++; int num1Baiwei = (num1 / 100); numTimes[num1Baiwei]++; } else { Initial(); continue; } int num2 = i*jShiwei; if (num2 < 1000) { int num2Gewei = num2 % 10; numTimes[num2Gewei]++; int num2Shiwei = (num2 / 10) % 10; numTimes[num2Shiwei]++; int num2Baiwei = (num2 / 100); numTimes[num2Baiwei]++; } else { Initial(); continue; } int num3 = i*jBaiwei; if (num3 < 1000) { int num3Gewei = num3 % 10; numTimes[num3Gewei]++; int num3Shiwei = (num3 / 10) % 10; numTimes[num3Shiwei]++; int num3Baiwei = (num3 / 100); numTimes[num3Baiwei]++; } else { Initial(); continue; } int res = i*j; int resGewei = res % 10; numTimes[resGewei]++; int resShiwei = (res / 10) % 10; numTimes[resShiwei]++; int resBaiwei = (res / 100) % 10; numTimes[resBaiwei]++; int resQianwei = (res / 1000) % 10; numTimes[resQianwei]++; int resWanwei = (res / 10000) % 10; numTimes[resWanwei]++; if (check()) { cout << res<<endl; system("pause"); return 0; } else { Initial(); continue; } } } cout << "Nothing" << endl; system("pause"); return 0;}
1 0
- 蓝桥杯模拟赛 猜算式
- 蓝桥杯模拟赛-猜算式
- 蓝桥杯模拟赛:猜算式
- 蓝桥杯模拟 猜算式
- 蓝桥杯2017模拟赛-猜算式
- 2017蓝桥杯模拟赛-猜算式
- 蓝桥杯模拟赛2017 猜算式
- 2017蓝桥杯 模拟赛 猜算式
- 2017年 蓝桥杯模拟赛,猜算式(纯暴力)
- 2017蓝桥杯模拟赛 Problem B: 猜算式(11分)
- 蓝桥杯-2017模拟赛本科试题-猜算式-java
- 蓝桥杯2017模拟题-猜算式
- 2017蓝桥模拟赛 猜算式
- 蓝桥杯--猜算式
- 蓝桥杯 猜算式
- 蓝桥杯 猜算式
- 蓝桥杯-猜算式
- [蓝桥杯]-猜算式
- java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for org.fkit
- 定位position
- 菜鸟的我
- linux快速生成大文件
- 银行卡号4位一空格
- 蓝桥杯模拟赛 猜算式
- CentOS更改yum源与更新系统
- Maven学习笔记(一)
- JS 闭包问题- for循环取 i
- PHP 范围解析操作符,__call(),__callstatic()的使用
- lpad
- Mybatis拦截器介绍及分页插件
- http post 返回中文乱码问题
- Android开发菜鸟到高手必备的十本畅销书籍