|
Revision 966, 1.3 kB
(checked in by alpt, 2 years ago)
|
Initial revision
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
#include <stdio.h> |
|---|
| 18 |
|
|---|
| 19 |
int main() |
|---|
| 20 |
{ |
|---|
| 21 |
int n,i, alloced=500, e, o, x; |
|---|
| 22 |
int *seq; |
|---|
| 23 |
char s[19]; |
|---|
| 24 |
|
|---|
| 25 |
n=0; |
|---|
| 26 |
seq=(int *)malloc(alloced*sizeof(int)); |
|---|
| 27 |
while(fgets(s, sizeof(s), stdin)) { |
|---|
| 28 |
if(s[0] == '\n') |
|---|
| 29 |
continue; |
|---|
| 30 |
|
|---|
| 31 |
seq[n]=atoi(s); |
|---|
| 32 |
|
|---|
| 33 |
n++; |
|---|
| 34 |
if(n == alloced) { |
|---|
| 35 |
alloced*=2; |
|---|
| 36 |
seq=(int *)realloc(seq, alloced*sizeof(int)); |
|---|
| 37 |
} |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
if(!n) |
|---|
| 41 |
goto finish; |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
for(i=1; i <= n/2; i++) { |
|---|
| 49 |
|
|---|
| 50 |
o=0; |
|---|
| 51 |
for(e=1; e*i <= n-i; e++) { |
|---|
| 52 |
|
|---|
| 53 |
for(x=0; x<i; x++) { |
|---|
| 54 |
|
|---|
| 55 |
if(seq[x] != seq[x+e*i]) |
|---|
| 56 |
break; |
|---|
| 57 |
} |
|---|
| 58 |
if(x < i) { |
|---|
| 59 |
o=1; |
|---|
| 60 |
break; |
|---|
| 61 |
} |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
if(!o) { |
|---|
| 65 |
for(o=0; o < i; o++) |
|---|
| 66 |
printf("%d ", seq[o]); |
|---|
| 67 |
printf("\n"); |
|---|
| 68 |
} |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
finish: |
|---|
| 72 |
free(seq); |
|---|
| 73 |
} |
|---|