链接

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

 /*
PROB:crypt1
ID:wanghan
LANG:C++
*/
#include "iostream"
#include "cstdio"
#include "cstring"
#include "string"
#include "vector"
using namespace std;
const int maxn=;
int n;
int vis[maxn];
int main()
{
freopen("crypt1.in", "r", stdin);
freopen("crypt1.out", "w", stdout);
cin>>n;
memset(vis,,sizeof(vis));
for(int i=;i<=n;i++){
int x;
cin>>x;
vis[x]=;
}
int cnt=;
for(int i=;i<=;i++){
for(int j=;j<=;j++){
if(i*j>) continue;
int num1=i,num2=j;
vector<int> n1,n2;
int t;
while(num1){
t=num1%;
n1.push_back(t);
num1/=;
}
while(num2){
t=num2%;
n2.push_back(t);
num2/=;
}
int flag=;
for(int k=;k<;k++){
if(!vis[n1[k]]){
flag=; break;
}
}
if(flag) continue;
for(int k=;k<;k++){
if(!vis[n2[k]]){
flag=; break;
}
}
if(flag) continue;
for(int k=;k<;k++){
int yy=;
for(int z=;z<;z++){
int zz=n2[k]*n1[z];
zz+=yy;
if(z==&&zz>=){
flag=; break;
}
int t=zz%;
yy=zz/;
if(!vis[t]){
flag=; break;
}
}
if(flag) break;
}
if(flag) continue;
int tt=i*j;
while(tt){
int hh=tt%;
if(!vis[hh]){
flag=; break;
}
tt/=;
}
if(flag) continue;
cnt++;
}
}
cout<<cnt<<endl;
return ;
}

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. p1211 Prime Cryptarithm

    直接深搜+检验. #include <iostream> #include <cstdio> #include <cmath> #include <algor ...

  7. 2312--1.3.4 Prime Cryptarithm 牛式

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

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

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

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

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

随机推荐

  1. FFT/NTT模板 既 HDU1402 A * B Problem Plus

    @(学习笔记)[FFT, NTT] Problem Description Calculate A * B. Input Each line will contain two integers A a ...

  2. Windows 10安装IntelliJ IDEA时快捷键冲突设置

    Windows的快捷键的非常多,而且个性化软件获得这些权限的也很多,所以没有最终的方法,只能不断的发现和尝试. 下面是收集的一些教程,或许能在这里找到灵感: 切记:不建议优先修改IDEA的快捷键,应该 ...

  3. Python学习系列之logging模块

    实例一:日志写进一个文件 代码: import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(filen ...

  4. 分布式搜索elasticsearch 基本概念

    ElasticSearch官网:http://www.elasticsearch.org/ 先上一张elasticsearch的整体框架图: ElasticSearch是基于Lucene开发的分布式搜 ...

  5. SQL server 数据存储过程

    创建视图

  6. python调用nmap进行扫描

    #coding=utf-8 import nmap import optparse import threading import sys import re ''' 需安装python_nmap包, ...

  7. MongoDB安装和简单介绍

    前面我们把nodejs的web开发入门说了,如今来说说数据库,一般搭配的数据库是mysql和mongodb,今天我们来说mongodb MongoDB是一个基于分布式文件存储的数据库,由C++语言编写 ...

  8. Spark 学习笔记:(三)Spark SQL

    参考:https://spark.apache.org/docs/latest/sql-programming-guide.html#overview http://www.csdn.net/arti ...

  9. C# delegate Action<T> lambda表达式

    转载以记录:http://blog.csdn.net/educast/article/details/7219854 在使用 Action<T> 委托时,不必显式定义一个封装只有一个参数的 ...

  10. ruby require

    require一般用来加载其它的类,如:  #Ruby代码  : require 'dbi'   require "rexml/document" 但是上面加载的是标准类库里面的文 ...