- 论坛徽章:
- 7
|
本帖最后由 rubyish 于 2017-10-08 20:42 编辑
1: change floor30.pl setting
- my $str =
- "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- my $want = 8;
- my $SIZE = 5; # 5.X G
复制代码
run:
perl floor30.pl > PART
output:
- head = 0 1142670.44 G
- head = 1 18430.17 G
- head = 2 302.13 G
- head = 3 5.04 G
- gen PART OK
- LENSTR = 62
- FINISH = 8
- HEAD = 3
复制代码
HERE:
LENSTR = 62
FINISH = 8
HEAD = 3
2: change floor30.c
- // --------- USER ----------
- str STR = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- # define LENSTR 26
- # define FINISH 8
- # define HEAD 3
- // ---------- E N D --------
复制代码
3: compile floor30.c
gcc -march=native -Ofast floor30.c -o floor30
4: cat file PART(226920 lines)
- 0 1 2
- 0 1 3
- 0 1 4
- 0 1 5
- 0 1 6
- 0 1 7
- 0 1 8
- 0 1 9
- 0 1 10
- 0 1 11
- ...
- ...
- 61 60 57
- 61 60 58
- 61 60 59
复制代码
5: run
part1: (FILE SIZE = 5.XG)
0 1 2 => file PART line 1
part2: 0 1 3 => file PART line 2
partX...
part226920:
- ./floor30 61 60 59 > part226920
复制代码
floor30.pl- #!/usr/bin/perl
- # version 26, subversion 0 (v5.26.0)
- use 5.024;
- # ____________________USER____________________
- my $str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- my $want = 8;
- my $SIZE = 5; # G 5.X G
- # ____________________MAIN____________________
- my $LEN = length $str;
- my @num = reverse 1 .. $LEN;
- my $HEAD;
- for my $head ( 0 .. $want ) {
- my $size = $want + 1;
- $size *= $_ for @num[ $head .. $want - 1 ];
- $size /= ( 1024 * 1024 * 1024 );
- printf STDERR "head = $head\t%.02f G\n", $size;
- if ( int($size) <= $SIZE ) {
- $HEAD = $head;
- last;
- }
- }
- print STDERR 'gen PART ';
- gimme();
- say STDERR "OK\n";
- say STDERR "LENSTR\t= $LEN";
- say STDERR "FINISH\t= $want";
- say STDERR "HEAD\t= $HEAD\n";
- # ____________________SUB____________________
- sub gimme { E_( [ 0 .. $LEN - 1 ], [] ) }
- sub E_ {
- my ( $a, $b ) = @_;
- if ( @$b == $HEAD ) {
- say "@$b";
- return;
- }
- for my $i ( 0 .. $#$a ) {
- E_( [ @$a[ 0 .. $i - 1, $i + 1 .. $#$a ] ], [ @$b, $a->[$i] ] );
- }
- }
- __DATA__
- $_
复制代码
floor30.c
- // gcc -march=native -Ofast floor30.c -o floor30
- # include <stdio.h>
- # include <stdlib.h>
- typedef char kar;
- typedef char *str;
- // --------- U S E R ----------
- str STR = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- # define LENSTR 26
- # define FINISH 8
- # define HEAD 3
- // ---------- E N D --------
- # define LENDIT (FINISH + 1)
- kar DAT[LENSTR];
- kar DIT[LENDIT];
- void floor30 (int);
- void help (str);
- /* ____________________ MAIN ____________________ */
- int main (int numa, str *para){
- if (numa != (HEAD + 1)) help (para[0]);
- int indes[HEAD];
- for (int i = 0; i < HEAD; i++) {
- indes[i] = atoi (para[i + 1]);
- DIT[i] = STR[indes[i]];
- }
- int head = HEAD;
- for (int i = 0; i < LENSTR; i++) {
- int ok = 1;
- for (int j = 0; j < HEAD; j++)
- if (i == indes[j]) {
- ok--; break;
- }
- if (ok) DAT[head++] = STR[i];
- }
- floor30 (HEAD);
- } /* main */
- /* _____________________ SUB _____________________ */
- void floor30 (int indes){
- static int has[LENSTR];
- if (indes == FINISH) {
- puts (DIT);
- return;
- }
- for (int i = HEAD; i < LENSTR; i++) {
- if (has[i]) continue;
- has[i] = 1;
- DIT[indes] = DAT[i];
- floor30 (indes + 1);
- has[i] = 0;
- }
- }
- void help (str app){
- printf ("\nUSE:\t%s", app);
- for (int i = 1; i <= HEAD; i++) printf (" n%d", i);
- puts ("");
- exit (1);
- }
复制代码
|
|