USACO 1.3 Prime Cryptarithm
来源:互联网 发布:学java好还是php好 编辑:程序博客网 时间:2024/05/16 12:38
开始时用数组对给出的数字加以标记,然后三位数 111--999 两位数11--99分别相乘加以判断。
/*ID: acmerfi1PROG: crypt1LANG: C++*/#include <stdio.h>#include <string.h>#include <stdlib.h>#define MAX 12int N;int hash[12], num, sum = 0;int exsit(int number) //判断是否在给定的数字中 {while(number){if(hash[number%10]) number /= 10;else return 0;}return 1;}int countDigit(int i, int j) // 计算乘积的位数 {int sum = i * j;int count = 0;if(exsit(i) && exsit(j) && exsit(sum)){while(sum){count++;sum /= 10;}}else return 0;return count;}int judge(int i, int j) // 判断是否满足题目中的条件 {if(4 == countDigit(i, j) && 3 == countDigit(i, j%10) && 3 == countDigit(i, j/10)){return 1;}else return 0;}int main(){freopen("crypt1.in", "r", stdin);freopen("crypt1.out", "w", stdout);memset(hash, 0, sizeof(num));scanf("%d", &N);for(int i = 0; i < N; i++){scanf("%d", &num);hash[num] = 1;}for(int i = 111; i <= 999; i++){for(int j = 11; j <= 99; j++){if(judge(i,j)) sum++;}}printf("%d\n", sum);return 0;}
- USACO 1.3-Prime Cryptarithm
- USACO 1.3 Prime Cryptarithm
- usaco 1.3 Prime Cryptarithm
- USACO 1.3 Prime Cryptarithm
- USACO 1.3 Prime Cryptarithm
- USACO 1.3-Prime Cryptarithm
- [USACO]Section 1.3 Prime Cryptarithm
- [USACO 1.3.4] Prime Cryptarithm
- usaco 1.3.4 Prime Cryptarithm
- USACO 1.3.4 Prime Cryptarithm
- USACO 1.3.5 Prime Cryptarithm
- usaco 1.3.4 Prime Cryptarithm
- USACO Section 1.3 Prime Cryptarithm
- USACO 1.3 Prime Cryptarithm (crypt1)
- usaco-1.3.4Prime Cryptarithm
- USACO Section 1.3 Prime Cryptarithm
- USACO 1.3. Prime Cryptarithm 牛式
- USACO 1.3.3 Prime Cryptarithm
- 触发器
- AT指令集相关内容
- 华为机试
- imsdroid 在google code上的下载地址
- 系统吞度量评估方法
- USACO 1.3 Prime Cryptarithm
- 2011-09-16 IT界的那点事
- java日志,需要知道的几件事
- 新浪微博首席架构师漫谈微博底层架构
- Oracle查询优化4大方面的主要途径
- sql插入记录到带标识列的表
- 触发器操作
- silverlight5 rc矢量打印
- Android中Intent传递对象的两种方法(Serializable,Parcelable)!