usaco1.3 crypt1 2008.11.5
来源:互联网 发布:七天网络怎么查分 编辑:程序博客网 时间:2024/06/07 03:18
usaco1.3 crypt1 2008.11.5
{Tips:
1.用到了哈希判重
2.这是一道简单的题,只要耐心就行了。}
{
ID:
PROG: crypt1
LANG: PASCAL
}
program kakashi; const oo:array[1..9]of char=('1','2','3','4','5','6','7','8','9'); var num:array[1..9,1..9,1..9,1..9]of -1..1; x,i,j,k,m,n,p,tot:longint; a:array[1..9]of 1..9; b:set of '0'..'9'; f1,f2:text; function deal(uu,la,lb:longint):boolean; var ux:string; lx,s:longint; begin if (uu>la)and(uu<lb) then begin str(uu,ux); lx:=length(ux); deal:=true; for s:=1 to lx do if not(ux[s]in b) then deal:=false; end else deal:=false; end; procedure find(y:longint); begin if deal(x*a[y],99,1000) then num[i,j,k,y]:=1 else num[i,j,k,y]:=-1; end; begin assign(f1,'crypt1.in'); reset(f1); assign(f2,'crypt1.out'); rewrite(f2); readln(f1,p); fillchar(num,sizeof(num),0); tot:=0; for i:=1 to p do read(f1,a[i]); for i:=1 to p do b:=b+[oo[a[i]]]; for i:=1 to p do for j:=1 to p do for k:=1 to p do begin x:=100*a[i]+10*a[j]+a[k]; for m:=1 to p do if (num[i,j,k,m]<>-1) then begin if (num[i,j,k,m]=0) then find(m); if num[i,j,k,m]=1 then for n:=1 to p do if (num[i,j,k,n]<>-1) then {=3=}begin if num[i,j,k,n]=0 then find(n); if num[i,j,k,n]=1 then if (deal(x*(10*a[m]+a[n]),999,10000)) then inc(tot); {=3=}end; {=1=} end; end; writeln(f2,tot); close(f1); close(f2); end.
data
TASK: crypt1
LANG: PASCAL
Compiling...
Compile: OK
Executing...
Test 1: TEST OK [0 secs]
Test 2: TEST OK [0.004 secs]
Test 3: TEST OK [0.004 secs]
Test 4: TEST OK [0 secs]
Test 5: TEST OK [0.004 secs]
Test 6: TEST OK [0.004 secs]
Test 7: TEST OK [0.004 secs]
All tests OK.
YOUR PROGRAM ('crypt1') WORKED FIRST TIME! That's fantastic
-- and a rare thing. Please accept these special automated
congratulations.
Here are the test data inputs:
------- test 1 -------
5
2 3 4 6 8
------- test 2 -------
4
2 3 5 7
------- test 3 -------
1
1
------- test 4 -------
7
4 1 2 5 6 7 3
------- test 5 -------
8
9 1 7 3 5 4 6 8
------- test 6 -------
6
1 2 3 5 7 9
------- test 7 -------
9
1 2 3 4 5 6 7 8 9
----------------------
Keep up the good work!
Thanks for your submission!
- usaco1.3 crypt1 2008.11.5
- USACO1.3.3 Prime Cryptarithm (crypt1)
- USACO1.3.3 Prime Cryptarithm (crypt1)
- usaco1.3 calfflac 2008.11.5
- usaco 1.3.3 crypt1
- crypt1-section1.3
- crypt1
- USACO-Section1.3 crypt1[DFS]
- usaco1.2 transform 2008.11.5
- usaco1.2 namenum 2008.11.5
- usaco1.2 palsquare 2008.11.5
- USACO1.5:sprime
- USACO1.5:pprime
- usaco1.5 pprime
- USACO1.3:skidesign
- USACO1.3:milk
- USACO1.3 wormhole
- usaco crypt1
- usaco1.2 palsquare 2008.11.5
- usaco1.3 calfflac 2008.11.5
- 【POI2005】【BZOJ1532】Kos-Dicing
- U盘容量显示错误修改
- Codeforces Round #341 (Div. 2)D. Rat Kwesh and Cheese
- usaco1.3 crypt1 2008.11.5
- [9] CMake - 如何高效使用"cmake --help" ?
- JFFS2 及其新特性
- 龙星镖局 | 2015 机器学习颁奖礼
- Codeforces AIM Tech Round (Div. 2) A. Save Luke
- TCP/IP–http协议(http报文格式) .
- 一元多项式的建立及其运算
- A Different Task
- 上手Android Studio