ywy_c_asm的良心题解

是道好题

体现了二进制位的形象递归思想,以及将FWT的思路(都是拆位分治)用到题目中的典范

可以暴力高斯消元。完全没有利用2^N以及+-1的良好性质

发现项数,方程和二进制位有关系

考虑类似FWT,FFT能不能递归?

已经具备递归的模式

但是怎样递归下去?
消掉x1的话,对应的位置,1010,0010,相加除以2,相减除以2,分别作为两边递归下去的答案,即可。

这样,通过化简规模,最终到了边界就可以直接得到解。

细节比较多

1.我是+用1,-用0,选择1用1,选择0用0,最后使得项数下标和最后选择的方程下标一致,直接得到答案

2.输出恶心,还是分治。注意别重复输出。其实写的好看一点,本质是线段树的x<<1,x<<1|1

3.读入double,不要强转int,可能是0.999999999999999,所以,x=round(100*df),四舍五入即可。

4.为了卡常,必须快输。

// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define reg register int
#define il inline
#define numb (ch^'0')
using namespace std;
typedef long long ll;
il void rd(int &x){
char ch;x=;bool fl=false;
while(!isdigit(ch=getchar()))(ch=='-')&&(fl=true);
for(x=numb;isdigit(ch=getchar());x=x*+numb);
(fl==true)&&(x=-x);
}
namespace Miracle{
int n;
int gcd(int a,int b){
return b?gcd(b,a%b):a;
}
struct node{
int u,d;
node(){}
node(ll s,ll m){
u=s;d=m;
}
node friend operator +(node a,node b){
return node(a.u+b.u,a.d);
}
node friend operator -(node a,node b){
return node(a.u-b.u,a.d);
}
node friend operator *(node a,ll b){
return node(a.u*b,a.d);
}
node friend operator /(node a,ll b){
return node(a.u,a.d*b);
}
void op(){
if(u<) putchar('-'),u=-u;
int g=gcd(u,d);
u/=g;d/=g;
printf("%d",u);
if(d!=) printf("/%d",d);
}
}c[<<];//,f[1<<20],g[1<<20];
char s[];
void get(){
scanf("%s",s);
int to=;
for(reg i=;i<n;++i){
if(s[i]=='+') to+=(<<i);
}
double df;
scanf("%lf",&df);
c[to].d=;c[to].u=round(df*100.0);
}
void div(int l,int r,int to,int cnt){
if(cnt==n){
//f[to]=c[to];
return;
}
int mid=(l+r)>>;
for(reg i=;i<(<<(n-cnt-));++i){
int t1=(i<<(cnt+))|(to)|(<<cnt);
int t0=(i<<(cnt+))|(to);//|(1<<cnt)
node tmp=c[t1];
c[t1]=(tmp-c[t0])/;
c[t0]=(tmp+c[t0])/;
}
div(l,mid,to,cnt+);
div(mid+,r,to|(<<cnt),cnt+);
}
bool has[<<];
void op(int s){
if(has[s]) return;
has[s]=;
if(c[s].u==) return;
c[s].op();
putchar(' ');
for(reg i=;i<n;++i){
if(s&(<<i)){
printf("x%d",i+);
}
}
puts("");
}
void out(int l,int r,int to,int cnt){
if(cnt==n-){
op(to);op(to|(<<cnt));op(to|(<<cnt)|(<<(cnt+)));op(to|(<<(cnt+)));
return;
}
if(!has[to])op(to);
int mid=(l+r)>>;
out(l,mid,to|(<<cnt),cnt+);
out(mid+,r,to,cnt+);
}
int main(){
rd(n);
for(reg i=;i<(<<n);++i) get();
// for(reg i=0;i<(1<<n);++i){
// cout<<c[i].u<<" "<<c[i].d<<endl;
// }
div(,(<<n)-,,);
if(n==){
op();op();return ;
}
out(,(<<n)-,,);
return ;
} }
signed main(){
Miracle::main();
return ;
} /*
Author: *Miracle*
Date: 2019/1/11 19:21:58
*/

[HEOI2014]逻辑翻译的更多相关文章

  1. [HEOI2014]逻辑翻译(分治)

    题目描述 在人类的神经系统中,每个信号都可以用?1或+1来表示.这些信号组合起来最后形成 了喜怒哀乐,酸甜苦辣,红黄绿蓝等各种各样的复杂信息.纳米探测科技的突破让生物学家 可以测量大脑中特定区域的完整 ...

  2. 洛谷 4106 / bzoj 3614 [HEOI2014]逻辑翻译——思路+类似FWT

    题目:https://www.luogu.org/problemnew/show/P4106 https://www.lydsy.com/JudgeOnline/problem.php?id=3614 ...

  3. 【Moqui业务逻辑翻译系列】Sales Representative Seeks Prospects and Opportunities 销售代表寻找期望合作对象和机会

    h1. Sales Representative Seeks Prospects and Opportunities 销售代表寻找期望合作对象和合作机会 h4. Ideas to incorporat ...

  4. 【Moqui业务逻辑翻译系列】Shipment Receiver Receives Shipment with Packing Slip but no PO

    Shipment Receiver receives shipment. It has invoice tucked into it. Receiver records vendor name, ve ...

  5. 【Moqui业务逻辑翻译系列】Story of Online Retail Company 在线零售公司的故事

    h1. Story of Online Retail Company 在线零售公司的故事 Someone decides to sell a product. [Product Marketer Ma ...

  6. 【Moqui业务逻辑翻译系列】--UBPL index

    h2. [UBPL Introduction] ubpl介绍h2. [Actor Definitions] 行为定义h2. General Business Process Stories 通常的商业 ...

  7. 【Moqui业务逻辑翻译系列】--UBPL Introduction同意的商业处理文库介绍

    h1. UBPL Introduction 通用的商业处理文库介绍h4. Why a Universal Business Process Library? 为什么需要通用的商业处理文库? The g ...

  8. 洛谷 P4106 / bzoj 3614 [ HEOI 2014 ] 逻辑翻译 —— 思路+递归

    题目:https://www.luogu.org/problemnew/show/P4106 https://www.lydsy.com/JudgeOnline/problem.php?id=3614 ...

  9. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

随机推荐

  1. OpenLDAP编译安装及配置

    原文发表于cu:2016-06-20 参考文档: 原理:http://seanlook.com/2015/01/15/openldap_introduction/ 官方文档: http://www.o ...

  2. Ubuntu18.04重装指南

    Guide google chrome sougou 谷歌服务助手\(\rightarrow\)谷歌访问助手(谷歌应用商店)登录谷歌账号(cnyalitea@gmail.com)然后同步. \(\te ...

  3. 斯坦福大学机器学习(Andrew Ng@2014)--自学笔记

    今天学习Andrew NG老师<机器学习>之6 - 6 - Advanced Optimization,做笔记如下: 用fminunc函数求代价函数最小值,分两步: 1.自定义代价函数 f ...

  4. 1.openldap介绍

    1.openldap介绍 OpenLDAP是轻型目录访问协议(Lightweight Directory Access Protocol,LDAP)的自由和开源的实现,在其OpenLDAP许可证下发行 ...

  5. Scrum立会报告+燃尽图(十一月二十一日总第二十九次):β阶段第二周分配任务

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2284 项目地址:https://git.coding.net/zhang ...

  6. 第四周 实验一 Java开发环境的熟悉 报告

    Java开发环境的熟悉 实验内容 1.IDEA的安装过程 2.使用IDEA代替虚拟机运行.编译.调试Java程序 实验要求 1.没有Linux基础的同学建议先学习<Linux基础入门(新版)&g ...

  7. mininet实验 可视化界面形成拓扑

    参考博客一 参考博客二 实验目的 mininet中内置了一个mininet可视化工具:miniedit.miniedit在mininet/mininet/examples目录下提供miniedit.p ...

  8. HDU 5183 Negative and Positive (NP) 前缀和+哈希

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5183 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

  9. OSG学习:使用OSG中预定义的几何体

    常用的内嵌几何体包括: osg::Box //正方体 osg::Capsule //太空舱 osg::Cone //椎体 osg::Cylinder //柱体 osg::HeightField //高 ...

  10. 1014 我的C语言文法定义与C程序推导过程

    程序> -> <外部声明> | <程序> <外部声明> <外部声明> -> <函数定义> | <声明> < ...