crypt1
来源:互联网 发布:淘宝网中年女羽绒服 编辑:程序博客网 时间:2024/06/06 18:41
Prime Cryptarithm
简述:
给定一些数字(没有零),满足下图的乘法竖式中凡每一个数都在这个数字集合中的,数字不限使用次数。有多少个这样的竖式。
这是一个三位数乘以两位数,需要枚举的数不多,111~999×11~99;依次判断符合标准的,以及过程中的数符合的。
代码:
#include <stdio.h>#include <stdlib.h>int n, a[10];int islegal(int x, int len);int ina(int x);int main(void){ freopen("crypt1.in", "r", stdin); freopen("crypt1.out", "w", stdout); int i, j,cnt = 0; scanf("%d", &n); for(i = 0; i < n; i++) scanf("%d", &a[i]); for(i = 111; i < 999; i++) { if(!islegal(i, 3))continue; for(j = 11; j < 99; j++) { if(!islegal(j, 2))continue; if(islegal(i * (j % 10), 3) && islegal(i * (j / 10), 3) && islegal(i * j, 4)) cnt++; } } printf("%d\n", cnt); return 0;}int islegal(int x, int len){ if(len == 2 && x > 99)return 0; if(len == 3 && x > 999)return 0; if(len == 4 && x > 9999)return 0; while(x > 0) { if(!ina(x % 10))return 0; x /= 10; } return 1;}int ina(int x){ int i; for(i = 0; i < n; i++) if(a[i] == x) return 1; return 0;}
阅读全文
0 0
- crypt1
- usaco crypt1
- 1.3 crypt1
- usaco crypt1
- usaco——crypt1
- 1.3 crypt1 简单枚举
- USACO 1.3 crypt1
- usaco 1.3.3 crypt1
- USACO 1.3 crypt1
- crypt1<uscao>1.3
- crypt1-section1.3
- USACO 1.3 Prime Cryptarithm (crypt1)
- USACO1.3.3 Prime Cryptarithm (crypt1)
- USACO1.3.3 Prime Cryptarithm (crypt1)
- usaco1.3 crypt1 2008.11.5
- USACO-Section1.3 crypt1[DFS]
- Unity3d 鼠标手势的左右滑动
- Spring定时任务注解@Scheduled(cron="*****?")
- PAT
- SpringBoot项目在IntelliJ IDEA中实现热部署
- 面试北京高思教育java开发考点总结---远程面试
- crypt1
- Redis之缓存设计
- unity exe运行时出现UnauthorizedAccessException: Access to the path“”is denied.
- spring事务的2种常用配置方式详解
- 自顶向下,逐步求精
- jdk8新特性(附jdk5/jdk6/jdk7新特性)
- JavaDVD管理系统
- 程序员如何入门 Python 爬虫
- 《剑指offer》刷题笔记(时间空间效率的平衡):第一个只出现一次的字符