当前位置: 首页 > news >正文

优秀集团网站设计wordpress扫码下载文件

优秀集团网站设计,wordpress扫码下载文件,泗水网站建设,wordpress实战斐波那契数列大家都非常熟悉。它的定义是#xff1a; f(x)1....(x1,2) f(x)f(x−1)f(x−2)....(x2) 对于给定的整数 n和 m#xff0c;我们希望求出#xff1a; f(1)f(2)…f(n)的值。 但这个值可能非常大#xff0c;所以我们把它对 f(m) 取模。 但这个数字依然很大 f(x)1....(x1,2) f(x)f(x−1)f(x−2)....(x2) 对于给定的整数 n和 m我们希望求出 f(1)f(2)…f(n)的值。 但这个值可能非常大所以我们把它对 f(m) 取模。 但这个数字依然很大所以需要再对 p 求模。 输入格式 输入包含多组数据。 每组数据占一行包含三个整数 n,m,p。 输出格式 每组数据输出一个整数表示答案。 每个数占一行。 数据范围 0n,m,p1018 测试数据不超过100组 输入样例1 2 3 5输出样例1 0 import java.util.Scanner;public class Main {public static int n;public static int m;public static int p;public static int te;public static int fei(int i) {if(i1)return 1;else if(i2)return 1;else if(i0)return 0;else return fei(i-1)fei(i-2);}public static void prin(int n,int m,int p) {int sum0;for(int j1;jn;j) {sumfei(j);}tefei(m);sumsum%te;sumsum%te;sumsum%p;System.out.print(sum\n);}public static void main(String[] args) {Scanner scnew Scanner(System.in);String sssc.nextLine();while(ss ! null) {String[] words ss.split( );nInteger.valueOf(words[0]);mInteger.valueOf(words[1]);pInteger.valueOf(words[2]);prin(n,m,p);sssc.nextLine();}sc.close();} } 我觉得重要的是连续输入3个一组的数据的处理 下面是一个例子 24 6 13 26 6 13 24 3 17 26 3 17 25 3 19 25 6 137 288 48 3157 288 46 8947 288 47 9748 288 9 3157 232135 12896 91547 1081143 31797 31479 4567872 123456 654321 4567874 123456 654321 这时候就要用字符串分割 另外我的方法超时了 下面是大佬的方法 public class _斐波那契 {public static void main(String[] args) {Scanner sc new Scanner(System.in);int n sc.nextInt();int m sc.nextInt();int p sc.nextInt();BigInteger fb_res new BigInteger(0);BigInteger m_res new BigInteger(m);BigInteger tmp new BigInteger(0);BigInteger P new BigInteger(p);for (int i 1; i n; i) {tmp fbn(i);fb_res fb_res.add(tmp);}m_res fbn(m);BigInteger res fb_res.mod(m_res).mod(P);System.out.println(res);}public static BigInteger fbn(int n) {BigInteger one new BigInteger(1);BigInteger zero new BigInteger(0);BigInteger[] dp new BigInteger[(n 1)];dp[0] zero;dp[1] one;for (int i 2; i n 1; i) {dp[i] dp[i - 1].add(dp[i - 2]);}return dp[n];} }作者caij2033 链接https://www.acwing.com/solution/content/34261/ 来源AcWing 著作权归作者所有。商业转载请联系作者获得授权非商业转载请注明出处。 有点子动态规划的样子在了 另外用BigInteger是我没想到的 BigInteger详解
http://www.pierceye.com/news/120696/

相关文章:

  • 户外旅游网站模板网站开发需要看相关书籍
  • 建设高端网站的公司企业营销网站建设公司
  • 重庆建设工程信息网站重庆企业网站建设报价
  • 大兴模版网站开发公司哪家好unn建站
  • 工信部网站域名备案查询北京科技网站建设公司
  • 昆明做网站那家好自己动手做网站
  • 女生做seo网站推广北京海岸设计公司网站
  • 单位建设网站硬件拍摄制作宣传片企业
  • 网站做推广应该如何来做呢哪里推广柳州360优化
  • 淘宝网站的建设目的济宁网站建设 中企动力临沂
  • 小米商城网站建设浏览器广告投放
  • 网站制作论文致谢wordpress首页导航栏
  • 网站右下角调用优酷视频广告代码酒泉地网站推广
  • 武清做网站的wordpress选择php
  • 最潮流的网站开发脚本语言icp网站备案
  • 盘锦网站建设平台wordpress英文模板
  • f2c网站建设公司单位名称大全
  • 泉州最专业手机网站建设哪家好重庆网站备案注销
  • 网站素材类型传统网站有没有建设必要性
  • 我的网站模板下载大连金普新区规划建设局网站
  • 营销案例网站织梦系统网站
  • 网站推广优化业务网站开发项目的里程碑
  • 小程序建站哪家好深圳建设银行官方网站
  • 免费红色ppt模板网站装修网站合作
  • iis7 添加网站古风头像在线制作免费
  • 电商网站构成网站尺寸自适应
  • 南昌网站建设咨询最简 wordpress主题
  • 污染网站代码建立官方网站
  • 整站网站模板乌海网站建设
  • 具体c2c网站建设实例商城网站建设价格最优