第一周訓練 E題

2021-07-27 22:54:05 字數 1391 閱讀 5056

函式 f:z

+→zf:z+→z

。已知 f(1

),f(

2)f(1),f(2)

的值,且對於任意 x

>

1x>1

,有 f(x

+1)=

f(x)

+f(x

−1)+

sin(πx

2)f(x+1)=f(x)+f(x−1)+sin⁡(πx2)

。求 f(n

)f(n)

的值。多組資料。(資料組數 t

≤100

t≤100

)每組資料報含 3

3 個不超過 10

9109

的正整數,分別代表 f(1

),f(

2)f(1),f(2)

和 nn 的值。

輸出 f(n

)mod(10

9+7)

f(n)mod(109+7)

。每組輸出末尾有換行符。

1 2 3

1 2 5

3

7

#include#include#includeusing namespace std;

struct matrix

;long long smod=(long long)100000007;

matrix mul(matrix a,matrix b)

matrix fastm(matrix a,int n)

return res;

}int main()

{ int n;

long long a1,a2;

matrix ma;

ma.m[0][0]=1;

ma.m[0][1]=0;

ma.m[0][2]=1;

ma.m[0][3]=1;

ma.m[1][0]=1;

ma.m[1][1]=0;

ma.m[1][2]=0;

ma.m[1][3]=0;

ma.m[2][0]=0;

ma.m[2][1]=1;

ma.m[2][2]=0;

ma.m[2][3]=0;

ma.m[3][0]=0;

ma.m[3][1]=0;

ma.m[3][2]=1;

ma.m[3][3]=0;

while(~scanf("%lld%lld%lld",&a1,&a2,&n))

{a1%=smod;

a2%=smod;

long long a3=((a1+a2)%smod+smod)%smod;

long long a4=((a2+a3-1)%smod+smod)%smod;

if(n==1)

cout<

演算法訓練第一周

leetcode 283 移動零 基礎寫法 class solution 設定指標i j 遍歷nums i 當nums i 0 即當值不為0時 nums j nums i j int j 0 for int i 0 i i 可以使i j指標同時向右移 只有當nums i 0 j才移動 造成j指標是慢...

pku 第一周訓練 模擬

給你一系列的左右括號的兩個表示方法,p和w.然後是有p向w轉換 pi表示第i個右括號前邊有幾個左括號 wi表示第i個右括號如果要找匹配的話,要找從後往前數幾個左括號與它匹配。include include include define maxn 25 using namespace std int ...

pku 第一周訓練 模擬

給你一系列的左右括號的兩個表示方法,p和w.然後是有p向w轉換 pi表示第i個右括號前邊有幾個左括號 wi表示第i個右括號如果要找匹配的話,要找從後往前數幾個左括號與它匹配。view code include include include define maxn 25 using namespac...