题目链接

我同学在旁边做者道题,我也看了一下

真的好水难

一看这道题,直接搜索

剪枝是不可能剪枝的一辈子不可能

Code

#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const long long MAXN = 105; long long n;
long long a[MAXN],b[MAXN];
bool sign = false;
bool flag[MAXN]; void dfs(long long now){
if (now == n){
for (int i = 1 ; i <= n ; i++){
printf("%lld ",b[i]);
}
sign = true;
return ;
} if (sign == true) return ; for (int i = 1 ; i <= n ; i++){
if (flag[i] == true) continue;
if(flag[i] == false){
if (b[now] * 2 == a[i] || (a[i] * 3 == b[now])){ //由于要当p[i] % 3 = 0 时
b[now + 1] = a[i];
flag[i] = true;
dfs(now + 1);
flag[i] = false;
}
}
} return ;
} int main(){
scanf("%lld",&n); for (int i = 1 ; i <= n ; i++) scanf("%lld",&a[i]); for (int i = 1 ; i <= n ; i++){
flag[i] = true;
b[1] = a[i];
dfs(1);
flag[i] = false;
} return 0;
}

CF977D Divide by three, multiply by two的更多相关文章

  1. Codeforces Round #479 (Div. 3) D. Divide by three, multiply by two

    传送门 D. Divide by three, multiply by two •题意 给你一个数 x,有以下两种操作,x 可以任选其中一种操作得到数 y 1.如果x可以被3整除,y=x/3 2.y= ...

  2. Divide by three, multiply by two CodeForces - 977D (思维排序)

    Polycarp likes to play with numbers. He takes some integer number xx, writes it down on the board, a ...

  3. Divide by three, multiply by two(DFS+思维)

    Polycarp likes to play with numbers. He takes some integer number x, writes it down on the board, an ...

  4. Codeforces 977D Divide by three, multiply by two(拓扑排序)

      Polycarp likes to play with numbers. He takes some integer number xx, writes it down on the board, ...

  5. Codeforces 977D: Divide by three, multiply by two(暴力)

    题意 有nnn个无序的数,对这些数进行排列,要求ai=3×ai+1a_i=3\times a_{i+1}ai​=3×ai+1​或2×ai=ai+12\times a_i=a_{i+1}2×ai​=ai ...

  6. Codeforces977D ---Divide by three, multiply by two 深搜+map存出现的数

    传送门:点我 题意:给定n长度的序列,重排成后一个数是前一个数除以三,或者后一个数是前一个数乘二,要求输出这个序列. 思路:大力深搜,对每个数搜除3的和乘2的是否出现过,然后继续搜下去.如果有一个数搜 ...

  7. Codeforces Round #479 (Div. 3) D. Divide by three, multiply by two (DFS)

    题意:给你一个长度为\(n\)的序列\(a\).对它重新排列,使得\(a_{i+1}=a_{i}/3\)或\(a_{i+1}=2*a_{i}\).输出重新排列后的序列. 题解:经典DFS,遍历这个序列 ...

  8. Java创建WebService服务及客户端实现(转)

    简介 WebService是一种服务的提供方式,通过WebService,不同应用间相互间调用变的很方便,网络上有很多常用的WebService服务,如:http://developer.51cto. ...

  9. Java浮点数float,bigdecimal和double精确计算的精度误差问题总结

    (转)Java浮点数float,bigdecimal和double精确计算的精度误差问题总结 1.float整数计算误差 案例:会员积分字段采用float类型,导致计算会员积分时,7位整数的数据计算结 ...

随机推荐

  1. 深入 .NET Core 基础 - 2:共享框架

    深入 .NET Core 基础 - 2:共享框架 原文地址:https://natemcmaster.com/blog/2018/08/29/netcore-primitives-2/ 共享框架从 . ...

  2. 震惊!线上四台机器同一时间全部 OOM,到底发生了什么?

    案发现场 昨天晚上突然短信收到 APM (即 Application Performance Management 的简称),我们内部自己搭建了这样一套系统来对应用的性能.可靠性进行线上的监控和预警的 ...

  3. SQL追踪器的安装和使用

    SQL追踪器主要作用快速查出错误SQL语言.此工具能几秒钟追踪出sql 数据库操作,能几分钟内分析任意项目系统数据库表结构,瞬间无刷新测试.调试 php代码 第一步:下载 https://pan.ba ...

  4. DevOps on DevCloud|如何采用流水线践行CI/CD理念【华为云技术分享】

    [摘要] 持续集成/持续交付(CI/CD,Continuous Integration/Continuous Deployment)在DevOps CMALS理念中具有支柱性地位,因而CI/CD流水线 ...

  5. 如何使用modelarts训练海量数据

    在modelarts上使用notebook上使用evs空间默认大小是5G,能满足大部分文本和图片训练模型的需求.如果训练数据稍微超过这个限额,可以适当的扩增下空间.但如果训练对象是视频,或是实际生成过 ...

  6. 二分查找-Java版

    /** * * 二分查找算法 * * * * @param srcArray 有序数组 * * @param target 查找元素 * * @return srcArray数组下标,没找到返回-1 ...

  7. luogu P1082 同余方程 |扩展欧几里得

    题目描述 求关于 x的同余方程 ax≡1(modb) 的最小正整数解. 输入格式 一行,包含两个正整数 a,ba,b,用一个空格隔开. 输出格式 一个正整数 x,即最小正整数解.输入数据保证一定有解. ...

  8. SpringMVC实现上传下载功能

    配置资源(jar包) 将前端页面整理好: 写核心的几个配置文件(applicationContext+wed.xml+jdbc.properties+log4j+springMVC.xml) 都是在s ...

  9. Orleans 序列化遇到的坑

    真的是巨坑 搞明白问题的我简直无法用言语来描述我的心情 先上架构图 理想中的架构 服务随便上 网关只负责分发 然后跟随官方教程写遇到了序列化问题 以前有经验,不慌,以前稀里糊涂就搞定了. 再然后遇到一 ...

  10. Seata 配置中心实现原理

    Seata 可以支持多个第三方配置中心,那么 Seata 是如何同时兼容那么多个配置中心的呢?下面我给大家详细介绍下 Seata 配置中心的实现原理. 配置中心属性加载 在 Seata 配置中心,有两 ...