# 1081: [SCOI2005]超级格雷码

## 1081: [SCOI2005]超级格雷码

Time Limit: 10 Sec  Memory Limit: 162 MB

Submit: 301  Solved: 159

[Submit][Status][Discuss]

2 2

00 01 11 10

## Source

``` 1 /**************************************************************
2     Problem: 1081
3     User: HansBug
4     Language: Pascal
5     Result: Accepted
6     Time:116 ms
7     Memory:1008 kb
8 ****************************************************************/
9
10 var
11    i,j,k,l,m,n:longint;
12    a,b:array[0..100000] of longint;
13    list:array[0..35] of char;
14 begin
16      for i:=0 to 9 do list[i]:=chr(48+i);
17      for i:=1 to 26 do list[9+i]:=chr(64+i);
18      fillchar(a,sizeof(a),0);
19      for i:=1 to n do b[i]:=1;a[1]:=-1;
20      k:=1;
21      for i:=1 to n do k:=k*m;
22      for l:=1 to k do
23          begin
24               i:=1;
25               while i<=n do
26                     begin
27                          if ((a[i]+b[i])>=m) or ((a[i]+b[i])<0) then
28                             begin
29                                  b[i]:=-b[i];
30                                  inc(i);
31                             end
32                          else
33                              begin
34                                   a[i]:=a[i]+b[i];
35                                   break;
36                              end;
37                     end;
38               for i:=1 to n do write(list[a[i]]);
39               writeln;
40          end;
42 end.    ```

251 篇文章37 人订阅

0 条评论

## 相关文章

### 2102: [Usaco2010 Dec]The Trough Game

2102: [Usaco2010 Dec]The Trough Game Time Limit: 10 Sec  Memory Limit: 64 MB Sub...

3737

2945

### 1643: [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪

1643: [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪 Time Limit: 5 Sec  Memory L...

3364

812

### BZOJ 1257: [CQOI2007]余数之和sum【神奇的做法，思维题】

1257: [CQOI2007]余数之和sum Time Limit: 5 Sec  Memory Limit: 162 MB Submit: 4474  So...

2594

### 3402: [Usaco2009 Open]Hide and Seek 捉迷藏

3402: [Usaco2009 Open]Hide and Seek 捉迷藏 Time Limit: 3 Sec  Memory Limit: 128 MB ...

3427

3414

1181

1012