战绩:第二题被叉掉了,最后1题,hack successful3人
传送门:
http://acm.hdu.edu.cn/showproblem.php?pid=5620
水,斐波那契额数列
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define ll long long
const int maxn=1e7+10;ll sum[maxn];ll n;ll pre[maxn];
int main(){
int t;cin>>t;sum[1]=1;sum[2]=2;pre[1]=1;pre[2]=3;
for(int i=3;i<=100;i++){
sum[i]=sum[i-1]+sum[i-2];
pre[i]=pre[i-1]+sum[i];
}
// cout<<pre[99]<<endl;
while(t--){
scanf("%I64d",&n);int num;
for(int i=1;i<=99;i++){
if(pre[i]>n){
num=i-1;break;
}
if(pre[i]==n) {
num=i;break;
}
}
printf("%d\n",num);
}
}
第二题:
http://acm.hdu.edu.cn/showproblem.php?pid=5621
圆上每四个点相连就会形成一个交点,所以最后答案就是Cn 4
水,注意会暴longlong,所以要每一步都除一下再连乘,正好差那么10的平方左右,也是叉人的好办法。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
#define LL unsigned long long
int main()
{
int T;
scanf("%d", &T);
while(T--){
LL n;
cin >> n;
LL ans1 = n;
LL t1 = n * (n - 1) / 2;
LL t2 = t1 * (n - 2) / 3;
LL t3 = (t2 * (n - 3)) / 4;
cout << ans1 + t3 << endl;
}
return 0;
}