import java.math.*; import java.io.*; //==========================================================C // OS(Quadratic Sieve) Program C // 2次ふるい法javaプログラム 原理プログラム C //----------------------------------------------------------C // 1. M = (int)sqrt(N) C // using Bsqrt C // 2. Seting the Factor Base C // Prime Table: PTB[NP] C // Factor Base: FTB[NB] C // 3. Sieving by QS C // Sieved Matrix: MQS[ND][NB] C //----------------------------------------------------------C // Written by Yasunori Ushiro , 2008/07/27 C // ( Tokyo Kougei University ) C // 後 保範: 東京工芸大学 C //==========================================================C public class TQS{ public static void main (String[] args) throws Exception { String s; int k, j; int NV[] = new int[2]; BigInteger N, M; int NB, ND; long t1,t2,t3,t4; double T1,T2,T3; // IO=0 --> 分解結果だけ出力、IO=1 --> 途中情報出力 // IO=2 --> 行列及び分解行列出力 int IO=2; // I/O File set FileInputStream fi = new FileInputStream("in.txt"); InputStreamReader in = new InputStreamReader(fi); BufferedReader bin = new BufferedReader(in); FileOutputStream fo = new FileOutputStream("Sieve.txt"); PrintWriter out = new PrintWriter(fo,true); s = bin.readLine(); N = new BigInteger(s); out.println("2次ふるい法による因数分解"); // QS t1 = System.currentTimeMillis(); int NP = 16; QS q = new QS(); M = q.QS(N, NP, NV); NB = NV[0]; ND = NV[1]; out.println("分解対象数="+N.toString()+", 平方根=" +M.toString()); out.println("基底="+NB+", データ="+ND+ ", ふるい数="+q.NOS); if(IO >= 1) { for (k=0; k= 2) { for (k=0; k=1 ) out.println("従属数="+ID); t3 = System.currentTimeMillis(); // Output AM & EM if(IO >= 2) { out.println("A+E"); for (k=0; k