crypt1解题报告 —— icedream61 博客园(转载请注明出处)
------------------------------------------------------------------------------------------------------------------------------------------------
【题目】
  用给出的N个数字,替换以下竖式,能生成多少个正确的竖式?
  * * *
  x * *
  -------
  * * *
  * * *
  -------
  * * * *
  输入文件,第一行N表示有N个数字,第二行给出所有数字(空格分割。)
【数据范围】
  所有数字∈{1,2,3,4,5,6,7,8,9}
【输入样例】
  5
  2 3 4 6 8
【输出样例】
  1
------------------------------------------------------------------------------------------------------------------------------------------------
【分析】
  竖式中,只要知道乘数和被乘数,就可以计算出下面三个结果。
  因此,只要枚举这两个数就好,一共5位,9^5<100000,一定没问题。
------------------------------------------------------------------------------------------------------------------------------------------------
【总结】
  一遍AC。
  样例一开始本机测试没过,原因是乘出来的三个结果没判断位数是否正确。可以说,还是读题不够严谨仔细。

------------------------------------------------------------------------------------------------------------------------------------------------

【代码】

 /*
ID: icedrea1
PROB: crypt1
LANG: C++
*/ #include <iostream>
#include <fstream>
using namespace std; int N,D[];
bool have[]; bool ok(int num)
{
while(num)
{
if(!have[num%]) return false;
num/=;
}
return true;
}
bool ok(int A,int B,int C,int D,int E)
{
int i = A*+B*+C;
int j = D*+E;
int x = i*E; if(x< || x>) return false;
int y = i*D; if(y< || y>) return false;
int z = x+y*; if(z< || z>) return false;
return ok(x) && ok(y) && ok(z);
} int main()
{
ifstream in("crypt1.in");
ofstream out("crypt1.out"); in>>N;
for(int i=;i<=N;++i) { in>>D[i]; have[D[i]]=true; } int s=;
for(int a=;a<=N;++a)
for(int b=;b<=N;++b)
for(int c=;c<=N;++c)
for(int d=;d<=N;++d)
for(int e=;e<=N;++e)
if(ok(D[a],D[b],D[c],D[d],D[e])) ++s;
out<<s<<endl; in.close();
out.close();
return ;
}

USACO Section1.3 Prime Cryptarithm 解题报告的更多相关文章

  1. USACO Section1.5 Prime Palindromes 解题报告

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

  2. USACO Section1.5 Superprime Rib 解题报告

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

  3. USACO Section1.5 Number Triangles 解题报告

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

  4. USACO Section1.4 Arithmetic Progressions 解题报告

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

  5. USACO Section1.3 Combination Lock 解题报告

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

  6. USACO Section1.3 Barn Repair 解题报告

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

  7. USACO Section1.3 Mixing Milk 解题报告

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

  8. USACO Section1.2 Palindromic Squares 解题报告

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

  9. USACO Section1.2 Dual Palindromes 解题报告

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

随机推荐

  1. *187. Repeated DNA Sequences (hashmap, one for loop)(difference between subsequence & substring)

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  2. Django QuestSet API (官方文档)

    1.返回新查询集的方法 (1)filter():滤指定条件的结果 Entry.objects.filter(pub_date__gt=datetime.date(2005, 1, 3), headli ...

  3. TeXstudio安装后提示no LaTeX distribution found on this system

    应该是设置一下用户变量,而非系统变量,用TeXLive 2015和MikTeX都不好使,最后设置了用户变量好使了 S:\TeX\MiKTeX 2.9\miktex\bin\x64\ 也是醉醉的 不过等 ...

  4. 解决Jenkins的错误“The Server rejected the connection: None of the protocols were accepted”

    1. 配置节点,配置好节点后,在节点机上运行已下载文件,双击执行,提示"The Server rejected the connection: None of the protocols w ...

  5. 线程属性总结 线程的api属性

    http://blog.csdn.net/zsf8701/article/details/7842392 //线程属性结构如下:typedef struct{ int etachstate; //线程 ...

  6. centos6 yum 安装 install c++4.8 gcc4.8

    cd /etc/yum.repos.d wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo yum --enablerep ...

  7. python 爬取猫眼榜单100(二)--多个页面以及多进程

    #!/usr/bin/env python # -*- coding: utf- -*- # @Author: Dang Kai # @Date: -- :: # @Last Modified tim ...

  8. lasagne保存网络参数

    # Optionally, you could now dump the network weights to a file like this: # np.savez('model.npz', *l ...

  9. web之HTTP协议

    1.web引用程序 web(world wide web)也叫万维网,是一种基于超文本和HTTP的.全球性的.动态交互的.跨平台的分布式图形信息系统.是建立在Internet上的一种网络服务,为浏览者 ...

  10. 关于var和ES6中的let,const的理解

    var的作用就不多说了,下面说说var的缺点: 1.var可以重复声明 var a = 1; var a = 5; console.log(a); //5 不会报错 在像这些这些严谨的语言来说,一般是 ...