bestcoder round 71 div2

14 篇文章 0 订阅

战绩:第二题被叉掉了,最后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;

}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值