USACO Prime Cryptarithm
来源:互联网 发布:mysql unique select 编辑:程序博客网 时间:2024/06/06 22:49
----------------------
/*ID: wangxin12PROG: crypt1LANG: C++*/#include <iostream>#include <fstream>#include <vector>#include <string>#include <set>#include <stdio.h>#include <stdlib.h>using namespace std;#define MAX 20001vector<int> num;bool flags(int index) {bool flag = false;for( int k = 0; k < num.size(); k++) {if( index == num[k] ) { flag = true;break;}}return flag;}int main() {//FILE * fin = fopen("crypt1.in", "r");ifstream fin("crypt1.in");ofstream fout("crypt1.out");int result = 0;int N;fin>>N;for(int k = 0; k < N; k++) {int temp;fin>>temp;num.push_back(temp);}/*cout<<N<<endl;for(int k = 0; k < numbers.size(); k++) {cout<<numbers[k]<<" ";} */for(int a = 0; a < N; a++)for(int b = 0; b < N; b++)for(int c = 0; c < N; c++)for(int d = 0; d < N; d++)for(int e = 0; e < N; e++){int first = (num[a] * 100 + num[b] * 10 + num[c]) * num[e] ;int second = (num[a] * 100 + num[b] * 10 + num[c]) * num[d];int temp = (num[a] * 100 + num[b] * 10 + num[c]) * (num[d] * 10 + num[e]);if( first > 999 || first < 100) continue;if( second > 999 || second < 100) continue;if( temp > 9999 || temp < 1000) continue;if( !flags(first % 10) || !flags( (first/10) % 10) || !flags( first/100)) continue;if( !flags(second % 10) || !flags( (second/10) % 10) || !flags( second/100)) continue;int s1 = temp % 10;int s2 = (temp % 100 - s1) / 10;int s3 = (temp % 1000 - s2 * 10 - s1) / 100;int s4 = (temp - s3 * 100 - s2 * 10 - s1) / 1000;bool b1 = false, b2 = false, b3 = false, b4 = false;for(int m = 0; m < num.size(); m++) {if( s1 == num[m] ) b1 = true;if( s2 == num[m] ) b2 = true;if( s3 == num[m] ) b3 = true;if( s4 == num[m] ) b4 = true;}if( b1 && b2 && b3 && b4) result++;}fout<<result<<endl;//fclose(fin);fin.close();fout.close(); return 0;}
- USACO Prime Cryptarithm Accepted
- Prime Cryptarithm(USACO)
- USACO 1.3-Prime Cryptarithm
- [USACO] Prime Cryptarithm
- USACO 1.3 Prime Cryptarithm
- USACO Prime Cryptarithm
- usaco Prime Cryptarithm
- [USACO]Prime Cryptarithm
- USACO Prime Cryptarithm 杂水题
- USACO:Prime Cryptarithm
- usaco 1.3 Prime Cryptarithm
- USACO Prime Cryptarithm
- USACO-Prime Cryptarithm
- USACO Prime Cryptarithm
- USACO Prime Cryptarithm
- usaco Prime Cryptarithm (暴力)
- USACO 1.3 Prime Cryptarithm
- USACO Prime Cryptarithm
- hdu 1754 I hate it(线段树)
- 貓空纜車 現代與自然的旅遊結合
- 【学习点滴-数据结构-二叉树】求二叉树两个节点之间的最大距离
- Linux下printf输出字体的特效
- 获取Oracle和mysql数据库服务器时间
- USACO Prime Cryptarithm
- table not mapped [
- .NET 连接Mysql的一种方式
- JQuery笔记
- 生产者消费者之爸爸妈妈儿子女儿苹果橘子编程实现
- Windows XP环境下部署Windows Phone开发工具
- JQuery案例(笔记)
- Java Management Extensions (JMX)
- JAR creation failed. See details for additional information解决方案