Advertisement
a53

easy_sum

a53
Sep 9th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. # include <fstream>
  2. #define MOD 1000000007ULL
  3. using namespace std;
  4. ifstream f("easy_sum.in");
  5. ofstream g("easy_sum.out");
  6. int n,x;
  7. unsigned long long int s=0ULL;
  8.  
  9. int main()
  10. {
  11. f>>n;
  12. for(int i=1;i<=n;++i)
  13. f>>x,s+=(n-i+1ULL)*i*x,s%=MOD;
  14. g<<s;
  15. return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement