sdnuoj1537(大数)

本文探讨了ACM竞赛中一个经典的子集求和问题,即给定n个数字,每次选择一个子集并求和,统计能够表示的数字总数。通过使用数学中的幂集概念,我们发现答案为2^n,展示了算法简洁之美。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Tiger Eat People
Description

As we all know, lls is the boss of SDNU ACM Training Team, so many team members may be afraid of him. But this is not the case, lls is very kindly to us. To show his love to us, he plan to give all of us an “Accepted”. The problem shows as follows:There are n numbers ​.Each time you can choose a subset of them(may be empty), and then add them up.Count how many numbers can be represented in this way.

Input

The first line of the input contains an integer T, denoting the number of test cases.
In each test case, there is a single integers n in one line, as described above.
, ​

Output

For each test case, output one line contains a single integer, denoting the answer.

Sample Input

4
9
7
8
233

Sample Output

512
128
256
13803492693581127574869511724554050904902217944340773110325048447598592

看的同学的博客hhh

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,n;
    unsigned long long m;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        //std::setprecision()控制输出n位有效数字
        //与fixed连用表示控制输出到小数点后几位
        //没有这俩会用e表示输出
        cout<<fixed<<std::setprecision(0)<<pow(2,n)<<'\n';
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值