直接深搜+检验。

#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. Redis,Memcache比较

    简单比较: Redis不仅仅支持简单的k/v类型的数据,同时还提供list,set,hash等数据结构的存储.memcache只支持简单的K/V类型数据, 不过memcache可以缓存其他东西如图片, ...

  2. SQL四大语句、四大完整性、五大约束

    四大语句: 1.数据定义语句: DDL:create.alter.drop.truncate(表结构) 2.数据操纵语句: DML:insert.delete.update.select 3.数据控制 ...

  3. 2017-2018-2 20165306 实验四《Android开发基础》实验报告

    实验四<Android开发基础>实验报告 实验报告封面 实验内容 Android程序设计-1 实验要求: 参考<Java和Android开发学习指南(第二版)(EPUBIT,Java ...

  4. 51nod 1366 贫富差距(flody)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1366 题意: 思路: 如果不是一个连通块的话,肯定是无穷大的. 用flo ...

  5. HDU 5573 Binary Tree(构造题)

    http://acm.hdu.edu.cn/showproblem.php?pid=5573 题意:给出一个满二叉树,根节点权值为1,左儿子为2*val,右儿子为2*val+1.现在有只青蛙从根节点出 ...

  6. Java只给汉字转URLEncoder

    public static String encode(String str, String charset) throws UnsupportedEncodingException { Patter ...

  7. 【Selenium2】【Python多线程】

    # all_tests_pro.py import unittest,time,os,multiprocessingimport HTMLTestRunner #查找多有含有thread的文件,文件夹 ...

  8. React Native的键盘遮挡问题(input/webview里)

    2017-06-15 1:使用keyVoaidView来解决 注意要设置behavio=“absolute”,哎.记性差 好像拼错了 2:使用下面的代码,监听键盘,然后将webView拉高就可以了 i ...

  9. hdu 3832 Earth Hour bfs

    Earth Hour Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others) Prob ...

  10. 【三十二】thinkphp之连接数据库、实例化模型

    1.连接数据库 Thinlphp内置了抽象数据库访问层,把不同的数据操作封装起来.我们只需要调用公共的DB类进行操作即可.DB类会自动调用相应的数据库驱动来处理. 在应用目录/common/conf/ ...