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. Linux 命令后台运行

    写这个随笔主要是每次Deepin用shadowsocks的时候总需要命令行启动,然后一个终端就一直开着总是点错了就给关了. (不知道为什么我的Deepin的shadowsocks-qt5总是连接不上的 ...

  2. MSD_radix_sort

    一.这次是在上一次尝试基础上进行的,预期是达到上次性能的9倍. MSD的基本手法就是不断切片.每一步都是把整体数据切割成256片,如上图所示,实际情况切片未必均匀,有的slice内可能一个元素也没有. ...

  3. set方法的使用

    <div id='root'> <div v-for='(item,key,index) of userInfo'> {{item}}--{{key}}--{{index}} ...

  4. UIView的层次调整,及子view布局模式自动布局模式(停靠模式)

    UIView*view1=[[UIView alloc]initWithFrame:CGRectMake(10,30,300,30)]; view1.backgroundColor=[UIColor ...

  5. Django Reverse for 'artic_post' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

    Reverse for 'home' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] ...

  6. MySQL与SQLServer的区别(一千条语句)

    ER图.分页.差异.Java连接MySQL SELECT * FROM table LIMIT [offset,] rows | rows OFFSET offset LIMIT 子句可以被用于强制 ...

  7. sup inf max min

    来自这里,觉得定义和举例都是最清楚的.http://www.math.illinois.edu/~ajh/347.summer14/completeness.pdf

  8. element-UI动态的循环生成Popover弹出框的方法

    父组件:<div class="itemLi" :class="{gray: (salse.flashsaleStatus==3 || salse.flashsal ...

  9. 7、SpringBoot+Mybatis整合------PageHelper简单分页

    开发工具:STS 代码下载链接:https://github.com/theIndoorTrain/SpringBoot_Mybatis/tree/1d30d2a573ce6784149a28af9b ...

  10. 使用winsw将spring-boot jar包注册成windows服务

    背景:最近的项目中使用spring-boot, https://github.com/kohsuke/winsw/releases <service> <id>YJPSS< ...