牛客挑战赛32 B 114514

8 篇文章 0 订阅
1 篇文章 0 订阅

给你一个长为n的序列
定义一个序列下标的子集为先辈,当且仅当选出的这些下标对应的序列值的乘积为114514,而且因为只有一只野兽,所以有个要求是选出来的这些下标所对应的序列值最多有一个1
请输出有多少先辈

输入描述:

第一行一个数表示n
之后一行n个数表示这个序列

n <= 229028,序列的值域在[0,1145141919]中

输出描述:

输出一行一个数表示答

示例1

输入

复制

2
1 114514

输出

复制

题意:给你n个数,问能找出多少个集合,集合内数的乘积等于114514

思路:114514的素因子只有2,31,1847三个,所有把值等于1,2,31,1847,2*31,2*1847,31*1847,2*31*1847的数纪录一下在算一下就好了,答案很大,得用__int128

#include<stdio.h>
#include <bits/stdc++.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 400000
//#define ll long long
#include<vector>
/*
2
31
1847
*/
inline void print(__int128 x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}
#define ll __int128
int main()
{
    long long n;
    scanf("%lld",&n);
    ll x0=0,x1=0,x2=0,x3=0,x12=0,x13=0,x23=0,x123=0;
    for(ll i=1;i<=n;i++)
    {
        long long x;
        scanf("%lld",&x);
        if(x==1) x0++;
        if(x==2) x1++;
        if(x==31) x2++;
        if(x==1847) x3++;
        if(x==2*31) x12++;
        if(x==2*1847) x13++;
        if(x==31*1847) x23++;
        if(x==114514) x123++;
    }
    ll ans=(x0+1)*((x1*x2*x3)+(x1*x23)+(x2*x13)+(x3*x12)+x123);
    print(ans);
    //printf("%lld",ans);
    printf("\n");
}

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值