giovedì, dicembre 22, 2016
concatenate pdf files with ubunbtu
$ pdfunite ES_0818_1.pdf ES_0818_2.pdf ES_0818_3.pdf ex_082018.pdf
In order to remove an (unknown) password from a protected pdf use this command:
$ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf
factorial with RecursiveTask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.ForkJoinPool; | |
import java.util.concurrent.ForkJoinTask; | |
import java.util.concurrent.RecursiveTask; | |
/** | |
* Created by enrico on 12/21/16. | |
*/ | |
public class Factorial { | |
private static class FactorialTask extends RecursiveTask<Long>{ | |
long n; | |
private FactorialTask(long n){ | |
this.n = n; | |
} | |
@Override | |
protected Long compute() { | |
if(n<=1) return 1L; | |
FactorialTask ft = new FactorialTask(n-1); | |
ft.fork(); | |
return n * ft.join(); | |
} | |
} | |
public long factorial(long n){ | |
ForkJoinTask<Long> fjt = new FactorialTask(n); | |
ForkJoinPool pool = new ForkJoinPool(); | |
return pool.invoke(fjt); | |
} | |
public static void main(String[] args) { | |
long result = new Factorial().factorial(5); | |
System.out.println(result); | |
} | |
} |
Iscriviti a:
Post (Atom)