求大佬看看。开long long 了还是60分

P2415 集合求和

``` #include<iostream> using namespace std; int main() { long long ar[1001], i = 0,cnt=0; long long sum=0,l=0; while (cin >> ar[i]) { cnt++; i++; } for (int j = 0; j < cnt; j++) { l=ar[j] << (cnt - 1); sum += l; } cout << sum; return 0; } ```
by Lovely_CCCyh___ @ 2023-04-18 21:28:39


试试这样QaQ ```cpp #include<bits/stdc++.h> using namespace std; int main() { int a[31],i=0,j; long long s=0; while(cin>>a[i++]); for(j=0;j<i;j++) { s+=a[j]; } s*=pow(2,i-2); cout<<s; return 0; } ```
by _Daniel_ @ 2023-04-18 21:30:43


@[_Daniel_](/user/954175) 谢谢啦,刚刚改好了
by snow_y @ 2023-04-18 22:47:45


@[cyh114514](/user/772909) 谢谢大佬,这样全用long long定义就AC了
by snow_y @ 2023-04-18 22:50:49


|