| 37 | |
| 38 | // 计算 ((a + b) * (c - d) + (a * c - b * d)) % mod 的非负结果 |
| 39 | public static int f2(long a, long b, long c, long d, int mod) { |
| 40 | int o1 = (int) (a % mod); // a |
| 41 | int o2 = (int) (b % mod); // b |
| 42 | int o3 = (int) (c % mod); // c |
| 43 | int o4 = (int) (d % mod); // d |
| 44 | int o5 = (o1 + o2) % mod; // a + b |
| 45 | int o6 = (o3 - o4 + mod) % mod; // c - d |
| 46 | int o7 = (int) (((long) o1 * o3) % mod); // a * c |
| 47 | int o8 = (int) (((long) o2 * o4) % mod); // b * d |
| 48 | int o9 = (int) (((long) o5 * o6) % mod); // (a + b) * (c - d) |
| 49 | int o10 = (o7 - o8 + mod) % mod; // (a * c - b * d) |
| 50 | int ans = (o9 + o10) % mod; // ((a + b) * (c - d) + (a * c - b * d)) % mod |
| 51 | return ans; |
| 52 | } |
| 53 | |
| 54 | public static void main(String[] args) { |
| 55 | System.out.println("测试开始"); |