Prime Cryptarithm
分析:对于三位数我们限定为[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的更多相关文章
- 洛谷P1211 [USACO1.3]牛式 Prime Cryptarithm
P1211 [USACO1.3]牛式 Prime Cryptarithm 187通过 234提交 题目提供者该用户不存在 标签USACO 难度普及- 提交 讨论 题解 最新讨论 题面错误 题目描述 ...
- l洛谷——P1211 [USACO1.3]牛式 Prime Cryptarithm
P1211 [USACO1.3]牛式 Prime Cryptarithm 题目描述 下面是一个乘法竖式,如果用我们给定的那n个数字来取代*,可以使式子成立的话,我们就叫这个式子牛式. *** x ** ...
- 洛谷 P1211 [USACO1.3]牛式 Prime Cryptarithm
P1211 [USACO1.3]牛式 Prime Cryptarithm 题目描述 下面是一个乘法竖式,如果用我们给定的那n个数字来取代*,可以使式子成立的话,我们就叫这个式子牛式. *** x ** ...
- USACO Section 1.3 Prime Cryptarithm 解题报告
题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...
- USACO 1.3.3 Prime Cryptarithm
题目链接:1.3.3 我用的枚举法,即每产生一组数据就判断是否是所给数字里的. AC还沾沾自喜,但一看题解,发现自己的代码真low... 在平时练习时,应该追求高效,精炼的代码,这样比赛时才能省出大量 ...
- p1211 Prime Cryptarithm
直接深搜+检验. #include <iostream> #include <cstdio> #include <cmath> #include <algor ...
- 2312--1.3.4 Prime Cryptarithm 牛式
Description 下面是一个乘法竖式,如果用我们给定的那n个数字来取代*,可以使式子成立的话,我们就叫这个式子牛式. * * * x * * ------- * * * * * * ------ ...
- USACO 1.3.4 Prime Cryptarithm 牛式(模拟枚举)
Description 下面是一个乘法竖式,如果用我们给定的那n个数字来取代*,可以使式子成立的话,我们就叫这个式子牛式. * * * x * * ------- * * * * * * ------ ...
- USACO Section1.3 Prime Cryptarithm 解题报告
crypt1解题报告 —— icedream61 博客园(转载请注明出处)--------------------------------------------------------------- ...
随机推荐
- 关于错误Access Violation和too many consecutive exceptions 解决方法
关于错误Access Violation和too many consecutive exceptions 解决方法 “如果DLL中用到了DELPHI的string类型,则DLL和主程序中都需要加上Sh ...
- Angular Material & Hello World
前言 Angular Material(下称Material)的组件样式至少是可以满足一般的个人开发需求(我真是毫无设计天赋),也是Angular官方推荐的组件.我们通过用这个UI库来快速实现自己的i ...
- vue之列表渲染
一.v-for循环用于数组 v-for 指令根据一组数组的选项列表进行渲染. 1.v-for 指令需要使用 item in items 形式的特殊语法,items 是源数据数组名, item 是数组元 ...
- Effective Java P2 Creating and Destroying Objects
This chapter concerns creating and destorying objects : when and how to create them, when and how to ...
- 【Java TCP/IP Socket】构建和解析自定义协议消息(含代码)
在传输消息时,用Java内置的方法和工具确实很用,如:对象序列化,RMI远程调用等.但有时候,针对要传输的特定类型的数据,实现自己的方法可能更简单.容易或有效.下面给出一个实现了自定义构建和解析协议消 ...
- 单点登录CAS-Demo
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[-] 1安全证书配置 2部署服务端CAS-Server 3部署CAS-Client 4测试SSO 1,安全证书配置 CAS默认 ...
- Spring-boot和Spring-Cloud遇到的问题
1.spring cloud 使用 feign 启动报错 错误信息 org/springframework/cloud/client/loadbalancer/LoadBalancedRetryFa ...
- Vue 开发线路 资料 汇总
线路 作者推荐学习线路 https://zhuanlan.zhihu.com/p/23134551 他人建议 https://www.cnblogs.com/smartXiang/p/6051086. ...
- Python常用的模块
模块,模块就是封装了特殊功能的代码. 模块分为三种: 自定义模块 第三方模块 内置模块 自定义模块 1.自定义模块 2.模块的导入 python有大量的模块可以使用,再使用之前我们只需要导入模块就可以 ...
- 关于Android滑动冲突的解决方法(二)
之前的一遍学习笔记主要就Android滑动冲突中,在不同方向的滑动所造成冲突进行了了解,这样的冲突非常easy理解,当然也非常easy解决.今天,就同方向的滑动所造成的冲突进行一下了解,这里就先以垂直 ...