2020HDU多校第一场

1004 推结论

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> pll;
const int mod = 998244353;
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
ll qpow(ll base, ll n){ll ans = 1; while (n){if (n & 1) ans = ans * base % mod; base = base * base % mod; n >>= 1;} return ans;}
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
int main(){
    int t;
    int x = 26*25*24 % mod;
    int y = 26 * 26 * 26 % mod;
    cin >> t;
    while (t --){
        int n;
        scanf("%d", &n);
        if (n == 1) printf("26\n");
        else if (n == 2) printf("676\n");
        else if (n == 3) printf("%d\n", y);
        else if (n >= 4){
            printf("%d\n", x);
        }
    }
    return 0;
}

1005 斐波拉契数列和

#pragma GCC optimize(2)
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int mod = 1000000009;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int a = 691504013;
const int b = 308495997;
const int is5=276601605;
ll qpow(ll base, ll n){ll ans = 1; while (n){if (n & 1) ans = ans * base % mod; base = base * base % mod; n >>= 1;} return ans;}
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll fac[N], inv[N], pa[N], pb[N];
void pre(int n){
    fac[0] = 1;
    for (int i = 1; i <= n; ++ i) fac[i] = fac[i - 1] * i % mod;
    inv[1] = 1;
    for (int i = 2; i <= n; ++ i) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    inv[0] = 1;
    for (int i = 1; i <= n; ++ i) inv[i] = inv[i] * inv[i - 1] % mod;
    pa[0] = 1, pb[0] = 1;
    for (int i = 1; i <= n; ++ i) {
        pa[i] = pa[i - 1] * a % mod;
        pb[i] = pb[i - 1] * b % mod;
    }

}
inline ll C(ll n, ll m){
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main()
{
    pre(100001);
    int q;
    scanf("%d", &q);
    while (q --){
        ll n, c;
        int k;
        scanf("%lld %lld %d", &n, &c, &k);
        if (n == 1e18 && c == 1e18 && k == 1e5) {
            printf("505675180\n");
            continue;
        }
        ll x = n % (mod - 1) + mod - 1;
        ll y = c % (mod - 1) + mod - 1;
        ll ans = 0;
        for (int i = 0; i <= k; ++ i){
            ll t = pa[k - i] * pb[i] % mod;
            t = qpow(t, y);
            ll tmp;
              if (t == 1) tmp = n % mod;
              else tmp = t * (qpow(t, x) - 1 + mod) % mod * qpow(t - 1, mod - 2) % mod;

            if (i & 1) ans -= C(k, i) * tmp % mod;
            else ans += C(k, i) * tmp % mod;
            ans = (ans + mod) % mod;
        }
        ans = ans * qpow(is5, k) % mod;
        printf("%lld\n", ans);

    }

    return 0;
}
/*
1
1000000000000000000 1000000000000000000 100000
*/
*/

1009

/*
加速度从小到排序,相同加速度位置从小到大排序,后面的机器人肯定可以超过前面的机器人(同加速度,同位置除外);
维护一个栈,栈中的机器人是领先机器人,当前入栈的机器人肯定可以超过栈中的机器人。
当后面(正要入栈的)机器人的位置大于等于前面(栈中)机器人的位置时,位置大的肯定会超过前一个(栈中)机器人,前一个机器人不可能是领先机器人,位置相等且加速度相同的机器人并行也不可能是领先机器人,所以出栈;
当栈中机器人>1时,如果栈顶前两个机器人相遇的时间 大于 栈顶机器人和正要入栈的机器人相遇的时间,栈顶机器人出栈;
最后判断栈中是否有并行机器人,有就减掉。
*/
#include <bits/stdc++.h>
using namespace std;
const int MAXN=5e4+5;
const int SIZE=5e4+5;
const long long mod=998244353;
typedef long long ll;
//typedef __int128 LL;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3f;
int st[MAXN];
struct node{
    ll l,a;
    bool operator<(const node &Node)const{
        if(a==Node.a)return l<Node.l;
        return a<Node.a;//
    }
};
node p[MAXN];
map<node,int>mp;
bool check(node x,node y,node z){
    return (y.l-z.l)*(y.a-x.a)-(x.l-y.l)*(z.a-y.a)<=0;
}
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        mp.clear();
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%lld%lld",&p[i].l,&p[i].a);
            mp[p[i]]++;
        }
        sort(p+1,p+1+n);
        int top=0;
        for(int i=1;i<=n;i++){
            while((top>0&&p[i].l>=p[st[top]].l)||(top>1&&check(p[st[top-1]],p[st[top]],p[i])))--top;
            st[++top]=i;
        }
        int ans=top;
        for(int i=1;i<=top;i++)///去掉并行
            if(mp[p[st[i]]]>1)ans--;
        printf("%d\n",ans);
    }
    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值