传送门

智障爆搜题

可以发现题目给出的式子可以移项

然后就是\(rev(N)-N=D\)

然后假设\(N=a_1*10^{n-1}+a_2*10^{n-2}+...+a_{n}\)

那么\(rev(N)=a_n*10^{n-1}+a_{n-1}*10^{n-2}+...+a_{1}\)

就容易得到\(\sum_{i=1}^{n/2}(a_n-a_{n-i+1})*(10^{n-i}-10^{i-1})\)

随便dfs一下就好了,注意一下一个n位的数可能由比n位大的数得到

代码:

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<cmath>
using namespace std;
void read(int &x){
char ch;bool ok;
for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=1e5+10;
int mm,m,n,a[60];
long long f[60];
long long ans;
void dfs(int x,int n,long long sum){
if(x==n/2+1){
if(sum==m){
long long now=a[1]>=0?(9-a[1]):(9+a[1]);
for(rg int i=2;i<x;i++)now=now*(a[i]>=0?(10-a[i]):(10+a[i]));
ans+=n&1?now*10:now;
}
return ;
}
if(sum+10ll*(f[n-x]-f[x-1])<m||sum-10ll*(f[n-x]-f[x-1])>m)return ;
for(rg int i=-9;i<10;i++){
a[x]=i;
dfs(x+1,n,sum+1ll*a[x]*(f[n-x]-f[x-1]));
}
}
int main(){
read(m),mm=m;f[0]=1;
while(mm)n++,mm/=10;
for(rg int i=1;i<=18;i++)f[i]=f[i-1]*10;
for(rg int i=n;i<=18;i++)dfs(1,i,0);
printf("%lld\n",ans);
}

AT2582 Mirrored的更多相关文章

  1. AT2582 [ARC075D] Mirrored

    首先因为这个问题的解的范围我们是不清楚的,可以先考虑一下解的范围以便后面的解题. 那么我们可以大胆猜测这个数的位数应该不会很长,否则除非使用一条与 \(D\) 有关的式子外,不论我们用什么方法都计算不 ...

  2. 最长回文子串(Mirrored String II)

    Note: this is a harder version of Mirrored string I. The gorillas have recently discovered that the ...

  3. [AtCoderContest075F]Mirrored

    [AtCoderContest075F]Mirrored 试题描述 For a positive integer \(n\), we denote the integer obtained by re ...

  4. Consistent 与 Mirrored 视角

    Consistent 与 Mirrored 视角 在进行分布式训练时,OneFlow 框架提供了两种角度看待数据与模型的关系,被称作 consistent 视角与 mirrored 视角. 本文将介绍 ...

  5. CentOS RabbitMQ 高可用(Mirrored)

    原文:https://www.sunjianhua.cn/archives/centos-rabbitmq.html 一.RabbitMQ 单节点 1.1.Windows 版安装配置 1.1.1 安装 ...

  6. 【arc075F】Mirrored

    Portal --> arc075_f Solution ​  一开始抱着"我有信仰爆搜就可以过"的心态写了一个爆搜.. ​  但是因为..剪枝和枚举方式不够优秀愉快T掉了q ...

  7. 【ARC075F】Mirrored 搜索/数位dp

    Description ​ 给定正整数DD,求有多少个正整数NN,满足rev(N)=N+Drev(N)=N+D,其中rev(N)rev(N)表示将NN的十进制表示翻转来读得到的数 Input ​ 一个 ...

  8. ARC075 F.Mirrored

    题目大意:给定D,询问有多少个数,它的翻转减去它本身等于D 题解做法很无脑,利用的是2^(L/2)的dfs,妥妥超时 于是找到了一种神奇的做法. #include <iostream> u ...

  9. Atcoder F - Mirrored(思维+搜索)

    题目链接:http://arc075.contest.atcoder.jp/tasks/arc075_d 题意:求rev(N)=N+D的个数,rev表示取反.例如rev(123)=321 题解:具体看 ...

随机推荐

  1. conda 里的 jupyter

    1. 安装conda https://mirrors.tuna.tsinghua.edu.cn/anaconda/ 下载并安装. 2. 安装jupyter (1)在ananconda主环境安装:pip ...

  2. Struts2 - 与 Servlet 耦合的访问方式访问web资源

    •       直接访问 Servlet API 将使 Action 与 Servlet 环境耦合在一起,  测试时需要有 Servlet 容器, 不便于对 Action 的单元测试. •       ...

  3. freeMarker(十四)——XML处理指南之必要的XML处理

    学习笔记,选自freeMarker中文文档,译自 Email: ddekany at users.sourceforge.net 1.基本内容 假设程序员在数据模型中放置了一个XML文档,就是名为 d ...

  4. Arc082_F Sandglass

    Description有一个沙漏由两个上下相通玻璃球$A$和$B$构成,这两个玻璃球都含有一定量的沙子,我们暂且假定$A,B$中位于上方的玻璃球的为$U$,下方的玻璃球为$L$,则除非$U$中没有沙子 ...

  5. C#中怎么解析JSON数据,并获取到其中的值?

    [1]首先我们根据创建一个json字符转 string json = @"[{'phantom':true,'id':'20130717001','data':{'MID':1019,'Na ...

  6. AtCoder Grand Contest 015 题解

    A - A+...+B Problem 常识 Problem Statement Snuke has N integers. Among them, the smallest is A, and th ...

  7. Python:模块详解及import本质

    转于:http://www.cnblogs.com/itfat/p/7481972.html 博主:东大网管 一.定义: 模块:用来从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能), ...

  8. samba server导出/datasmb/目录;samba client挂载/data/至本地的/mydata目录;本地的mysqld或mariadb服务的数据目录设置为/mydata, 要求服务能正常启动,且可正常 存储数据;

    实验环境:CentOS7 主机(mini2) :172.16.250.247  主机名::localhost 客户端(mini3):172.16.253.99  主机名:pxe99 #主机:配置文件的 ...

  9. ng2 样式控制之style绑定和class绑定

  10. shell入门-连接符(并且、和、或者)

    特殊符号:&& 说明:并且,左右两边是两条命令,左面的执行成功才会去执行右面的命令.右. 特殊符号:|| 说明:或者,左右两边是两条命令,左边的命令执行不成功,才会执行右面的命令 &a ...