日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

中石油训练赛 - Faulhaber’s Triangle(打表)

發布時間:2024/4/11 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 中石油训练赛 - Faulhaber’s Triangle(打表) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目描述

The sum of the m-th powers of the first n integers

can be written as a polynomial of degree m + 1 in n:

For example:
S(n, 1) = (1 + . . . + n) = (1/2) ? n2+ (1/2) ? n
S(n, 2) = (1 + . . . + n2) = (1/3) ? n3+ (1/2) ? n2+ (1/6) ? n
S(n, 3) = (1 + . . . + n3) = (1/4) ? n4+ (1/2) ? n3) + (1/4) ? n2
S(n, 4) = (1 + . . . + n4) = (1/5) ? n5+ (1/2) ? n4) + (1/3) ? n3?? (1/30) ? n
The coefficients F(m, k) of these formulas form Faulhaber’s Triangle:
1
1/2 1/2
1/6 1/2 1/3
0 1/4 1/2 1/4
-1/30 0 1/3 1/2 1/5
0 -1/12 0 5/12 1/2 1/6
1/42 0 -1/6 0 1/2 1/2 1/7
where rows m start with 0 (at the top) and columns k go from 1 to m + 1
Each row of Faulhaber’s Triangle can be computed from the previous row by:
a) The element in row i and column j (j > 1) is (i/j) ? (theelementaboveleft); that is: F(i, j) =(i/j) ? F(i ? 1, j ? 1)
b) The first element in each row F(i, 1) is chosen so the sum of the elements in the row is 1.
Write a program to find entries in Faulhaber’s Triangle as decimal fractions in lowest terms .

?

輸入

The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set should be processed identically and independently.
Each data set consists of a single line of input consisting of three space separated decimal integers.
The first integer is the data set number. The second integer is row number m, and the third integer is the index k within the row of the entry for which you are to find F(m, k), the Faulhaber’s Triangle entry (0 ≤ m ≤ 400, 1 ≤ k ≤ m + 1).

?

輸出

For each data set there is a single line of output. It contains the data set number, followed by a single space which is then followed by either the value if it is an integer OR by the numerator of the entry, a forward slash and the denominator of the entry.

?

樣例輸入

4 1 4 1 2 4 3 3 86 79 4 400 401

樣例輸出

1 -1/30 2 1/3 3 -22388337 4 1/401題目鏈接:點擊查看

題目大意:給出公式:

  • 當j!=1時,
  • 當j==1時,
  • 初始化F(0,1)=1,求指定位置的值

    題目分析:這個題目給了很多無用的信息,但讀懂需要打表后寫一個函數打完表然后直接查詢就行了,為了防止爆范圍,我特地用了long long分別儲存分子和分母,并寫了一個化簡函數,每次都除以兩個數的gcd來約分,并且將分母上的符號轉移到分子上方便輸出,直接上代碼吧,簡單打表:

    #include<iostream> #include<string> #include<cstring> #include<cmath> #include<algorithm> using namespace std; typedef long long LL;const int N=500;LL a[N][N],b[N][N];//分子,分母 void huajian(LL &a,LL &b) {LL gcd=__gcd(a,b);a/=gcd;b/=gcd;if(a<0&&b<0)//如果都為負數,全部轉正{a=-a;b=-b;}if(a>=0&&b<0)//如果符號在分母上,則轉移到分子上{a=-a;b=-b;} }void init() {a[0][1]=1;b[0][1]=1;for(int i=1;i<=400;i++){LL suma=0;//suma和sumb儲存第2~i+1列的值的總和LL sumb=1;//初始化為0/1(分數形式)for(int j=2;j<=i+1;j++){a[i][j]=i*a[i-1][j-1];b[i][j]=j*b[i-1][j-1];huajian(a[i][j],b[i][j]);LL tempa=suma*b[i][j]+sumb*a[i][j];//根據通分求和化簡的LL tempb=sumb*b[i][j];huajian(tempa,tempb);suma=tempa;sumb=tempb;}a[i][1]=sumb-suma;//最后給F(i,1)賦值b[i][1]=sumb;huajian(a[i][1],b[i][1]);} }int main() {init();int w;cin>>w;while(w--){int num,x,y;scanf("%d%d%d",&num,&x,&y);printf("%d %lld",num,a[x][y]);if(b[x][y]!=1)printf("/%lld",b[x][y]);printf("\n");}return 0; }

    ?

    總結

    以上是生活随笔為你收集整理的中石油训练赛 - Faulhaber’s Triangle(打表)的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 久久免费精彩视频 | 欧洲美女与动交zozzo | 麻豆视频观看 | 美女高潮网站 | 婷婷久久伊人 | 全国最大色 | 视频二区中文字幕 | 老地方在线观看免费动漫 | 女同动漫免费观看高清完整版在线观看 | 色人阁视频| 18精品爽国产白嫩精品 | 久久婷婷影视 | 精品免费一区 | 黑人一区 | 久久久久久久久影院 | 二级毛片 | 亚洲伦理中文字幕 | 国产资源在线观看 | ass东方小嫩模pics | 妞干网这里只有精品 | 国产剧情自拍 | 色欲亚洲Av无码精品天堂 | 男生操女生逼逼 | 麻豆视频在线观看 | 无码少妇一区二区三区 | 少妇激情偷人爽爽91嫩草 | 精品一区二区三区电影 | 国产女人精品 | 一二三四区视频 | 91调教视频 | 天堂网在线资源 | 精品一区二区三区免费毛片 | 中文在线字幕免费观看电 | 夫妻性生活自拍 | 国产精品久久久久久久久久久免费看 | 黄色资源网| 日本少妇做爰全过程毛片 | 国产黄色录相 | 在线观看 亚洲 | 午夜美女视频 | 国内偷拍精品视频 | aaaaa级片 | 中文字幕精品一区二区精 | 欧美日韩精品一区二区在线播放 | 亚洲一区二区三区激情 | 国产精品一色哟哟哟 | 欧美操老女人 | 国产伦理精品 | 日韩久久精品一区二区 | 国产人妻人伦精品1国产丝袜 | 亚洲视频一区 | 日韩在线不卡视频 | 亚洲一级影院 | 国产一区二区三区四区五区美女 | 免费极品av一视觉盛宴 | 二区三区免费 | 草视频在线 | 国产黄色一区二区三区 | 在线看黄免费 | 久久久久毛片 | 婷婷色吧 | 精品亚洲一区二区三区四区五区 | k8yy毛片| 91丝袜| www国产精品内射熟女 | 俺来也俺也啪www色 欧洲一区二区视频 | 久久精品无码毛片 | 椎名空在线 | 99在线免费观看 | 亚洲精品9999 | 男女扒开双腿猛进入爽爽免费 | 久久深夜福利 | 成年人网站免费在线观看 | 国产破处视频 | 91插插插永久免费 | 黄色片在线观看免费 | 天堂中文在线网 | 亚洲精品污一区二区三区 | 色婷婷六月天 | 制服丝袜亚洲色图 | 国产麻豆电影在线观看 | 一级片免费观看 | 中文字幕观看av | 亚洲无吗在线观看 | 91精品国产91久久久久久黑人 | 久久av无码精品人妻出轨 | 97国产精品视频人人做人人爱 | 丝袜国产视频 | 天堂√8在线中文 | 国产色91| 国产在线黄色 | 伊人丁香| 就爱av | 激情国产 | 日韩欧美猛交xxxxx无码 | 日韩日b视频 | 6080一级片| 夜夜夜夜夜操 | a级免费毛片 |