链接

分析:对于三位数我们限定为[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. 简单div遮罩

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. Codevs1062路由选择

    /* #include<iostream> #include<cstdio> #include<cstring> #define MAXN 301 using na ...

  3. Spring中Beans的自动装配概述

    以下内容引用自http://wiki.jikexueyuan.com/project/spring/beans-autowiring.html: 在之前的做法上会参照这样的顺序:1.使用<bea ...

  4. IOS --关于粘贴板 ,剪切板 ,UILabel的复制

    在iOS中下面三个控件,自身就有复制-粘贴的功能: 1.UITextView 2.UITextField 3.UIWebView UIKit framework提供了几个类和协议方便我们在自己的应用程 ...

  5. iOS 内存管理策略

    内存管理策略(memory Management Policy) NSObject protocol中定义的的方法和标准命名惯例一起提供了一个引用计数环境,内存管理的基本模式处于这个环境中.NSObj ...

  6. How to fill the background with image in landscape in IOS? 如何使image水平铺满屏幕

    UIImageView *backgroundImage = [[UIImageView alloc] initWithFrame:self.view.frame];    [backgroundIm ...

  7. sqlmap sql 注入攻击

  8. [Testing] Static Analysis Testing JavaScript Applications

    The static code analysis and linting tool ESLint is the de-facto standard for linting JavaScript pro ...

  9. CSS样式布局入门介绍,非常详尽

    转载自:http://wenboxz.com/archives/try-css-layout.html/

  10. Oracle创建索引的原则(转)

    Oracle 建立索引及SQL优化 数据库索引: 索引有单列索引复合索引之说 如何某表的某个字段有主键约束和唯一性约束,则Oracle 则会自动在相应的约束列上建议唯一索引.数据库索引主要进行提高访问 ...