题解:P2415 集合求和
Victor_Wayne · · 题解
本蒟蒻第一次写题解,不喜勿喷。
一看到这题,本蒟蒻就想到暴力,喜提5个 TLE。
https://www.luogu.com.cn/record/221584209
后来看了上面那位大大的代码,本蒟蒻恍然大悟。
上 AC 代码:
#include<bits/stdc++.h>
using namespace std;
int a[31],i=1,j;
long long s=0;
int main(){
while(cin>>a[i])i++;
for(j=1;j<=i;j++){
s+=a[j];
}
s*=pow(2,i-2);
cout<<s;
return 0;
}
后话:
虽然本蒟蒻 " 借鉴" 了上面的代码,但该说的还是要说。
首先,由于
完