欢迎辞

欢迎来到“笃志以砺,决起而飞”!
如果您是第一次来到本站,建议访问本站导读以便更快地了解本站。
如果您喜欢本站,欢迎订阅

 

2012 年五月
« 四  
 123456
78910111213
14151617181920
21222324252627
28293031 

USACO 1.2 Dual Palindromes 双重回文数 程序

Compiling…
Compile: OK

Executing…
Test 1: TEST OK [0.000 secs, 208 KB]
Test 2: TEST OK [0.000 secs, 204 KB]
Test 3: TEST OK [0.032 secs, 204 KB]
Test 4: TEST OK [0.000 secs, 204 KB]
Test 5: TEST OK [0.000 secs, 204 KB]
Test 6: TEST OK [0.011 secs, 204 KB]
Test 7: TEST OK [0.000 secs, 204 KB]

All tests OK.
Your program (‘dualpal’) produced all correct answers at the first time!
Here are the test data inputs:

——- test 1 ——-
5 1
——- test 2 ——-
9 10
——- test 3 ——-
15 9900
——- test 4 ——-
10 90
——- test 5 ——-
12 125
——- test 6 ——-
12 1900
——- test 7 ——-
8 500

Keep up the good work!

Thanks for your submission!

?View Code PASCAL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
ID:cxj6661
PROB:dualpal
LANG:PASCAL
}
//By Ceeji
//Date: 2009-6-1
//Type: NO
//Resource: USACO 1.2
Program dualpal;
Const
   fin='dualpal.in';
   fou='dualpal.out';
Var
   i,n,s,ss:longint;
Function translate(i,b:longint):string;
var s:string;
    j,p,k:longint;
begin
    if i=0 then exit('0');
    s:='';
    j:=i;
    while true do
    begin
       p:=j div b;
       k:=j-p*b;
       j:=p;
       if (p=0) then
       begin
          if k<10 then s:=chr(48+k)+s
                  else s:=chr(55+k)+s;
          exit(s);
       end;
       if k<10 then s:=chr(48+k)+s else s:=chr(55+k)+s;
    end;
    if s='' then exit('0');
end;
Function ishuiwen(s:string):boolean;
var i,l:longint;
    s2:string;
begin
    l:=length(s); s2:='';
    for i:=l downto 1 do
    begin
       s2:=s2+s[i];
    end;
    if s2=s then exit(true) else exit(false);
end;
Function isok(ii:longint):boolean;
var j,k:longint;
begin
   k:=0;
   for j:=2 to 10 do
   begin
     if ishuiwen(translate(ii,j)) then inc(k);
     if k=2 then exit(true);
   end;
   exit(false);
end;
begin
   assign(input,fin);  reset(input);
   assign(output,fou); rewrite(output);
   readln(n,s);
   close(input); ss:=0; i:=s+1;
   while ss<n do
   begin
      if isok(i) then begin inc(ss); writeln(i); end;
      inc(i);
   end;
   close(output);
end.

您也许喜欢

  1. USACO 1.2 Palindromic Squares 程序
  2. USACO 1.3 Mixing Milk 程序
  3. USACO The Perfect Stall (stall4) 程序
  4. USACO 4.2 ditch Drainage Ditches 程序
  5. USACO 1.2 Milking Cows(milk2) 程序
  6. USACO 1.2 Name That Number(namenum) 程序

2 comments to USACO 1.2 Dual Palindromes 双重回文数 程序

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>