2020 camp-day6-N
乘法有分配律,怎么贪心都对,真妙啊
想了个贪心,一下过了好开心,结果只要贪心正确就必定过,哭了
#include <cstdio> #define RE register #define FOR(i,a,b) for(RE int i=a;i<=b;++i) #define sc(n) scanf("%d",&n) #define ll long long using namespace std; int n, a,b; ll sum; int main() { sc(n);sc(a); FOR(i,2,n)sc(b),sum += 1ll*a*b,a+=b; printf("%lld",sum); return 0; } //不论合并顺序