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

购物app大全/南宁seo外包服务商

购物app大全,南宁seo外包服务商,react做门户网站,腾讯url短网址在线生成题意: 四个数字,可以改变顺序,中间可以添加,-,*符号。数字之间还可以合并成一个数。 求最终能生成多少个数字。 思路: 暴力枚举生成了哪几个数,再枚举这几个数之间符号是啥,再用栈算出这个结果&#xff0c…

题意:
四个数字,可以改变顺序,中间可以添加+,-,*符号。数字之间还可以合并成一个数。
求最终能生成多少个数字。

思路:
暴力枚举生成了哪几个数,再枚举这几个数之间符号是啥,再用栈算出这个结果,用set去重。
写的贼麻烦,快麻了。

#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
set<int>st;
int get(deque<pair<int,int>>que) {deque<pair<int,int>>d = que;deque<pair<int,int>>now;while(!que.empty()) {pair<int,int>num = que.front();que.pop_front();if(num.first == 1 && num.second == 2) {pair<int,int>nex = que.front();que.pop_front();pair<int,int>pre = now.back();now.pop_back();int number = nex.second * pre.second;now.push_back({0,number});} else {now.push_back(num);}}que = now;now.clear();while(!que.empty()) {pair<int,int>num = que.front();que.pop_front();if(num.first == 1) {if(num.second == 0) {pair<int, int> nex = que.front();que.pop_front();pair<int, int> pre = now.back();now.pop_back();int number = nex.second + pre.second;now.push_back({0,number});} else if(num.second == 1) {pair<int, int> nex = que.front();que.pop_front();pair<int, int> pre = now.back();now.pop_back();int number = pre.second - nex.second;now.push_back({0,number});}} else {now.push_back(num);}}return now.front().second;
}
void fuhao(int id,vector<int>v,deque<pair<int,int>>que) {if(id == v.size() - 1) {que.push_back({0,v[id]});int num = get(que);if(num >= 0) {st.insert(num);}return ;}que.push_back({0,v[id]});for(int i = 0;i < 3;i++) { //+ - *que.push_back({1,i});fuhao(id + 1,v,que);que.pop_back();}
}
void cal(vector<int>v) {if(v.size() == 1) return;deque<pair<int,int>>que;fuhao(0,v,que);
}
vector<vector<int>>vec;
int a[10];
void dfs(int id,int now,vector<int>v) {if(id == 5) {if(now) v.push_back(now);vec.push_back(v);return;}if(now) v.push_back(now);dfs(id + 1,a[id],v);if(now) v.pop_back();now = now * 10 + a[id];dfs(id + 1,now,v);
}
int main() {scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4]);sort(a + 1,a + 1 + 4);do {vector<int> v;dfs(1, 0, v);}while(next_permutation(a + 1,a + 1 + 4));for(int i = 0;i < vec.size();i++) {cal(vec[i]);}printf("%d\n",st.size());return 0;
}
http://www.lbrq.cn/news/835255.html

相关文章:

  • wordpress显示所有tag/网站关键词优化排名技巧
  • 公司建设网站费用如何入帐/seo网站优化报价
  • 做宣传网站要多少钱/今日大新闻
  • 在线客服网站系统/seo关键词优化案例
  • 网站制作的核心要点是什么/百度上传自己个人简介
  • 网站搜索排名和什么有关系/微信公众号的推广
  • 网站查询系统怎么做/百度推广点击软件
  • 国外网站建站/seo 优化思路
  • 郑州做网站好的公司/百度seo排名优化如何
  • 移动wordpress+到根目录/关键词seo排名公司
  • 第一次做网站选多大空间/构建新发展格局
  • 制作做的网站如何上传网上/什么是百度快照
  • 丰台网站建设推广/网上教育培训机构排名
  • 哈尔滨精品建站/新闻头条今日要闻国内新闻最新
  • 建网站的流程及注意事项/网页设计作品集
  • 开发游戏app/下载班级优化大师
  • 做网站需要多大空间/如何推广自己的产品
  • 云建网站网址/温州seo排名优化
  • 如何做彩票网站的源码/seo零基础教学
  • 昆明网站建设服务至上/腾讯云建站
  • 网站后台管理系统下载/搜索引擎排名谷歌
  • 建网站的公司叫什么/seo是搜索引擎营销吗
  • 不同代码做的网站后期维护情况/深圳百度开户
  • 光谷网站推广/优化大师的优化项目有哪7个
  • 学做湘菜的视频网站/网站竞价推广
  • 网站开发课程设计报告/淘宝流量
  • 电子商务网站策划ppt/自己的网站怎么建立
  • 中国建设注册中心网站/搜索关键词优化排名
  • 申请个人手机网站空间/舆情监测
  • 淄博网站制作托管优化/关键词seo优化
  • 【服务器与部署 12】数据库生产环境部署实战:MySQL、PostgreSQL、Redis高可用配置全攻略
  • Python应用指南:使用PyKrige包实现ArcGIS的克里金插值法
  • arping(ARP协议网络测试工具)
  • wpf 实现窗口点击关闭按钮时 ​​隐藏​​ 而不是真正关闭,并且只有当 ​​父窗口关闭时才真正退出​​ 、父子窗口顺序控制与资源安全释放​
  • CSS手写题
  • Spring AI 项目实战(十六):Spring Boot + AI + 通义万相图像生成工具全栈项目实战(附完整源码)