先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7
深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新大数据全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
如果你需要这些资料,可以添加V获取:vip204888 (备注大数据)
正文
反之结果为(f(n+2)-1)%f(m)%p==f(n+2)%f(m)%p-1。
直接上代码,其实很多时候看debug是最快的调试方案:
package com.example.demo2022110201;
/**
* @author
*/
import java.math.BigInteger;
import java.util.Scanner;
public class Demo1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 三变量
long n, m, p;
n = sc.nextLong();
m = sc.nextLong();
p = sc.nextLong();
BigInteger bigP = BigInteger.valueOf(p);
if (m >= n + 2) {
BigInteger ans = fib(n + 2, bigP);
System.out.println(ans.mod(bigP).longValue() - 1);
} else {
BigInteger fib_m = fib(m);
BigInteger ans = fib(n + 2, fib_m);
System.out.println(ans.mod(fib_m).mod(bigP).longValue() - 1);
}
sc.close();
}
/**
* 快速矩阵求fib
*
* @param m
* @return
*/
private static BigInteger fib(long m) {
BigInteger[][] ans = mPow(m - 2);
return ans[0][0].add(ans[1][0]);
}
private static BigInteger fib(long m, BigInteger mod) {
BigInteger[][] ans = mPow(m - 2, mod);
return ans[0][0].add(ans[1][0]);
}
/**
* 矩阵快速幂
*
* @param n
* @return
*/
private static BigInteger[][] mPow(long n) {
BigInteger[][] a =
{{BigInteger.ONE, BigInteger.ONE}, {BigInteger.ONE, BigInteger.ZERO}};
//基础矩阵
BigInteger[][] ans =
{{BigInteger.ONE, BigInteger.ZERO}, {BigInteger.ZERO, BigInteger.ONE}};
while (n != 0) {
if ((n & 1) == 1) {
BigInteger t1 = ans[0][0];
BigInteger t2 = ans[1][0];
ans[0][0] = ans[0][0].multiply(a[0][0]).add(ans[0][1].multiply(a[1][0]));
ans[0][1] = t1.multiply(a[0][1]).add(ans[0][1].multiply(a[1][1]));
ans[1][0] = ans[1][0].multiply(a[0][0]).add(ans[1][1].multiply(a[1][0]));
ans[1][1] = t2.multiply(a[0][1]).add(ans[1][1].multiply(a[1][1]));
}
BigInteger t1 = a[0][0];
BigInteger t2 = a[1][0];
BigInteger t3 = a[0][1];
a[0][0] = a[0][0].multiply(a[0][0]).add(a[0][1].multiply(a[1][0]));
a[0][1] = t1.multiply(a[0][1]).add(a[0][1].multiply(a[1][1]));
a[1][0] = a[1][0].multiply(t1).add(a[1][1].multiply(a[1][0]));
a[1][1] = t2.multiply(t3).add(a[1][1].multiply(a[1][1]));
n >>= 1;
}
return ans;
}
private static BigInteger[][] mPow(long n, BigInteger mod) {
BigInteger[][] a =
{{BigInteger.ONE, BigInteger.ONE}, {BigInteger.ONE, BigInteger.ZERO}};
//基础矩阵
BigInteger[][] ans =
{{BigInteger.ONE, BigInteger.ZERO}, {BigInteger.ZERO, BigInteger.ONE}};
while (n != 0) {
if ((n & 1) == 1) {
//结果乘当前平方
BigInteger t1 = ans[0][0];
BigInteger t2 = ans[1][0];
ans[0][0] = ans[0][0].multiply(a[0][0]).add(ans[0][1].multiply(a[1][0])).mod(mod);
ans[0][1] = t1.multiply(a[0][1]).add(ans[0][1].multiply(a[1][1])).mod(mod);
ans[1][0] = ans[1][0].multiply(a[0][0]).add(ans[1][1].multiply(a[1][0])).mod(mod);
ans[1][1] = t2.multiply(a[0][1]).add(ans[1][1].multiply(a[1][1])).mod(mod);
}
//算平方
BigInteger t1 = a[0][0];
BigInteger t2 = a[1][0];
BigInteger t3 = a[0][1];
**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注大数据)**
![img](https://img-blog.csdnimg.cn/img_convert/74c40a78864844f9569aa00350fe78ec.png)
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
img-KBKSZBKj-1713440802929)]
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**