题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2817
题意:给你一个数列的前三项,让你求第k项,这个数列可能是等差也可能是等比
解析:直接判断等差还是等比,等比用快速幂,等差就直接套公式a0+(n-1)*d
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2817
题意:给你一个数列的前三项,让你求第k项,这个数列可能是等差也可能是等比
解析:直接判断等差还是等比,等比用快速幂,等差就直接套公式a0+(n-1)*d
本文介绍了SEQUENCE的使用场景和相关的函数的使用方法,并对使用SEQUENCE过程中遇到的常见问题及解决方法进行了汇总。
Number Sequence
A sequence of numbershttp://acm.hdu.edu.cn/showproblem.php?pid=2817Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1594 Accepted Submission(s): 494 Problem DescriptionXinlv wrote some sequences on the paper a long time ago, they might be arithmet
题意: 给出a,b,c,k,四个数;由 a,b,c构成一个非递减的等差数列或等比数列;求数列的第k个值; 其中等比数列需要用到快速幂的算法;#include<stdio.h>#define mod 200907long long multy(long long q,long long n)//快速幂运算{ long long cnt=n; long long base=q; long long ret=1; while(cnt>0) { if(cnt&1) ret=ret*base%mod; cnt=c...
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M