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 博客园(转载请注明出处)--------------------------------------------------------------- ...
随机推荐
- BZOJ——1571: [Usaco2009 Open]滑雪课Ski
http://www.lydsy.com/JudgeOnline/problem.php?id=1571 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: ...
- HUD 1506 Largest Rectangle in a Histogram
Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- 精通python网络爬虫之自动爬取网页的爬虫 代码记录
items的编写 # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentati ...
- IntelliJ IDE 各种插件的安装和使用
插件的安装和使用持续的更新中...........................................................
- java通过反射获取bean字段注解@Column中的信息
直接上代码吧: Field field; Field[] fields=clas.getDeclaredFields(); for (int i = 0; i <fields.length ; ...
- Linux最常用的命名
一.环境配置 vim /etc/sysconfig/network-scripts/ifcfg-eth0 vim /etc/sysconfig/network vim /etc/hostname vi ...
- 《Java虚拟机原理图解》1.4 class文件中的字段表集合--field字段在class文件中是怎样组织的
0.前言 了解JVM虚拟机原理是每一个Java程序员修炼的必经之路.但是由于JVM虚拟机中有很多的东西讲述的比较宽泛,在当前接触到的关于JVM虚拟机原理的教程或者博客中,绝大部分都是充斥的文字性的描述 ...
- Spring MVC使用Schedule实现定时任务
Schedule存在spring-context.jar包中. 实现简单步骤: 1.配置bean.xml开启定时任务支持. <?xml version="1.0" encod ...
- Android PullToRefresh 下拉刷新,上拉很多其它,支持ScrollView,ListView,可方便拓展GridView,WebView等
在写着东西之前.从网上找到非常多这方面的源代码,可是基本没有找到惬意的.包含在GitHub上的比較有名的Android-PullToRefresh-master.思来想去还是自己写吧.当然当中借鉴了一 ...
- Youth is not a time of life, it is a state of mind.
青春不是生命的一段,而是一种精神状态.