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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

Seq(HDU-6672)

發布時間:2025/3/17 编程问答 13 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Seq(HDU-6672) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Problem Description

度度熊有一個遞推式?
其中 a1=1。現給出 n,需要求 an。

Input

第一行輸入一個整數?T,代表?T?(1≤T≤100000) 組數據。?
接下?T?行,每行一個數字 n?(1≤n≤1012)。?

Output

輸出 T 行,每行一個整數表示答案。

Sample Input

5
1
2
3
4
5

Sample Output

1
1
0
3
0

思路:打個表找規律即可

void get(){a[1]=1;for(int i=2;i<=100;i++){int sum=0;for(int j=1;j<i;j++)sum+=(j*a[j]);a[i]=sum%i;} }

Source Program

#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include<cstring> #include<cmath> #include<ctime> #include<algorithm> #include<utility> #include<stack> #include<queue> #include<vector> #include<set> #include<map> #include<bitset> #define EPS 1e-9 #define PI acos(-1.0) #define INF 0x3f3f3f3f #define LL long long #define Pair pair<int,int> const int MOD = 1E9+7; const int N = 6000+5; const int dx[] = {0,0,-1,1,-1,-1,1,1}; const int dy[] = {-1,1,0,0,-1,1,-1,1}; using namespace std;int main() {int t;scanf("%d",&t);while(t--) {LL n;scanf("%lld",&n);LL res=0;if(n%2) {if((n-1)%6==0)res=(n-1)/6*4+1;else {if((n-3)%6==0)res=(n-3)/6;elseres=(n-5)/6;}}else {if(n<4)res=n/2;else if((n-4)%6==0)res=n-1;elseres=n/2;}printf("%lld\n",res);}return 0; }

?

總結

以上是生活随笔為你收集整理的Seq(HDU-6672)的全部內容,希望文章能夠幫你解決所遇到的問題。

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