这道题
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
unsigned long long ans,s[35],last;
int main()
{
int n=1;
while(cin>>s[n])n++;
n--;
cout<<"the n is:"<<n<<endl;
for(int i=1;i<=n;i++)
{
ans+=last;
last+=s[i];
cout<<"the ans is:"<<ans<<" the last is:"<<last<<endl;
for(int j=i+1;j<=n;j++)
{
last+=s[j];
ans+=last;
cout<<"the ans is:"<<ans<<" the last is:"<<last<<endl;
}
}
cout<<ans;
return 0;
}
这样改了好几次都不能过,就看了题解.题解区里一片叫数学题的(所以不算标题党 )
然后主要的问题就是各位如果不看题解是怎么想到规律的,又怎样培养发现数学规律这方面的能力的?