直接深搜+检验。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF;
int n,tot;
vector<int> vct; int getr(vector<int> &x,int pos)
{
int res=;
for(int i=;i<;++i)
{
res+=x[pos]*x[i]*pow(,i)+0.5;
}
return res;
} bool chk(int x,int dgt)
{
int std=pow(,dgt)+0.5;
if(x>=std)return ;
for(;x;)
{
if(find(vct.begin(),vct.end(),x%)==vct.end())return ;
x/=;
}
return ;
} void dfs(vector<int> &x)
{
if(x.size()==)
{
int res1=getr(x,);
int res2=getr(x,);
int res=res1+res2*; if(chk(res1,)&&chk(res2,)&&chk(res,))
{
//cout<<res1<<" "<<res2<<" "<<res<<endl;
++tot;
}
return;
}
for(int i=;i<vct.size();++i)
{
x.push_back(vct[i]);
dfs(x);
x.pop_back();
}
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
cin>>n;
vct.assign(n,);
for(int i=;i<n;++i)
{
cin>>vct[i];
}
vector<int> tmp;
dfs(tmp);
cout<<tot<<endl;
}
return ;
}

p1211 Prime Cryptarithm的更多相关文章

  1. 洛谷P1211 [USACO1.3]牛式 Prime Cryptarithm

    P1211 [USACO1.3]牛式 Prime Cryptarithm 187通过 234提交 题目提供者该用户不存在 标签USACO 难度普及- 提交  讨论  题解 最新讨论 题面错误 题目描述 ...

  2. l洛谷——P1211 [USACO1.3]牛式 Prime Cryptarithm

    P1211 [USACO1.3]牛式 Prime Cryptarithm 题目描述 下面是一个乘法竖式,如果用我们给定的那n个数字来取代*,可以使式子成立的话,我们就叫这个式子牛式. *** x ** ...

  3. 洛谷 P1211 [USACO1.3]牛式 Prime Cryptarithm

    P1211 [USACO1.3]牛式 Prime Cryptarithm 题目描述 下面是一个乘法竖式,如果用我们给定的那n个数字来取代*,可以使式子成立的话,我们就叫这个式子牛式. *** x ** ...

  4. USACO Section 1.3 Prime Cryptarithm 解题报告

    题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...

  5. USACO 1.3.3 Prime Cryptarithm

    题目链接:1.3.3 我用的枚举法,即每产生一组数据就判断是否是所给数字里的. AC还沾沾自喜,但一看题解,发现自己的代码真low... 在平时练习时,应该追求高效,精炼的代码,这样比赛时才能省出大量 ...

  6. 2312--1.3.4 Prime Cryptarithm 牛式

    Description 下面是一个乘法竖式,如果用我们给定的那n个数字来取代*,可以使式子成立的话,我们就叫这个式子牛式. * * * x * * ------- * * * * * * ------ ...

  7. USACO 1.3.4 Prime Cryptarithm 牛式(模拟枚举)

    Description 下面是一个乘法竖式,如果用我们给定的那n个数字来取代*,可以使式子成立的话,我们就叫这个式子牛式. * * * x * * ------- * * * * * * ------ ...

  8. USACO Section1.3 Prime Cryptarithm 解题报告

    crypt1解题报告 —— icedream61 博客园(转载请注明出处)--------------------------------------------------------------- ...

  9. Prime Cryptarithm

    链接 分析:对于三位数我们限定为[100,999],两位数我们限定为[10,99],然后我们依次判断是否满足乘法式且各个数位是否在数列中,若都满足+1 /* PROB:crypt1 ID:wangha ...

随机推荐

  1. Google Protobuf结合Netty实践

    1.Win版Protobuf代码生成工具下载: https://github.com/protocolbuffers/protobuf/releases 注意下载protoc-3.6.1-win32. ...

  2. 【教程】Git在Eclipse中的安装和基本使用

    一.安装 点击 Help->Install New Software->add 安装地址为:http://download.eclipse.org/egit/updates/ 选择插件   ...

  3. CF1137C Museums Tour

    思路 强连通分量的好题 对于每个博物馆,因为时间的限制条件,不好直接统计, 发现d很小,可以建出d层分层图,原图<u,v>的边变成<u,i>到<v,i+1>的边,& ...

  4. [thymeleaf] - 1.Thymeleaf是什么

    Thymeleaf是⾯向Web和独⽴环境的现代服务器端Java模板引擎,能够处 理HTML,XML,JavaScript,CSS甚⾄纯⽂本. Thymeleaf旨在提供⼀个优雅的.⾼度可维护的创建模板 ...

  5. (转载)http和socket之长连接和短连接区别

    TCP/IPTCP/IP是个协议组,可分为三个层次:网络层.传输层和应用层.在网络层有IP协议.ICMP协议.ARP协议.RARP协议和BOOTP协议.在传输层中有TCP协议与UDP协议.在应用层有: ...

  6. Python实现机器学习算法:朴素贝叶斯算法

    ''' 数据集:Mnist 训练集数量:60000 测试集数量:10000 ''' import numpy as np import time def loadData(fileName): ''' ...

  7. com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction

    本文为博主原创: 以下为在程序运行过程中报的错误, org.springframework.dao.CannotAcquireLockException: ### Error updating dat ...

  8. Linux安装Broadcom无线驱动

    参考https://blog.csdn.net/u012833250/article/details/52493806 首先查看自己的网卡型号,然后先执行sudo apt-get update 再根据 ...

  9. MInio python

    # Install Minio library. # $ pip install minio # # Import Minio library. from minio import Minio # I ...

  10. 【Python】【有趣的模块】【requests】【一】HTTP头信息总结

    [HTTP请求 == 请求行 + 消息报头 + 请求正文 ] 请求行:Method Request-URL HTTP-Version CRLF HTTP协议定义了许多与服务器交互的方法 ① PUT:请 ...