import java.util.*; /* * Problem: Inflation (NAIPC19) * Author: Alex Coleman * Complexity: O(y^3*c + c^3*y + q*(y^2+c^2)) * * All operations in the problem are multiplication; by taking the log of * all values, the operations become addition. Then, we simply have a system * of linear equations, and a set of query linear expressions. * This can be solved by applying gaussian elimination to the input equations, then * 'eliminating' the query expressions. */ public class Inflation_arc { public static void main(String[] args) { Scanner in = new Scanner(System.in); int y = in.nextInt(); int c = in.nextInt(); int q = in.nextInt(); double[] inflations = new double[y-1]; for(int i=0;i Math.abs(m[sr][pc])) sr = j; swap(m, sr, pr); if (eq(m[pr][pc],0)) { pc++; continue; } if(pc == C-1) { System.err.println("Data is inconsistent"); System.exit(1); } double piv = m[pr][pc]; for (int j = pc; j < C; j++) m[pr][j] /= piv; for (int j = 0; j < R; j++) { if(j == pr) continue; double ratio = -m[j][pc]; for (int k = pc; k < C; k++) { m[j][k] += m[pr][k] * ratio; } } pc++; pr++; } } }