AlbertMourato

Untitled

Mar 1st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <bits/stdc++.h>
  3. //%lld
  4. typedef long long ll;
  5. #define si(a) scanf("%d", &a)
  6. #define sii(a, b) scanf("%d%d", &a, &b)
  7. #define pi(a) printf("%d\n", a)
  8.  
  9. using namespace std;
  10. ll vetor[10000000];
  11.  
  12. int main(){
  13.     //freopen("in.txt", "r", stdin);
  14.     //freopen("out.txt", "w", stdout);
  15.     int t, d, k;
  16.     int e;
  17.     cin>>t;
  18.     while(t--){
  19.         int p = 0;
  20.         int temp = 0;
  21.         ll saida = 0;
  22.         cin>>e;
  23.         for(int i = 0;i<=e;i++)cin>>vetor[i];
  24.         cin>>d>>k;
  25.         for(int i = 0;;i++){
  26.             p+=d;
  27.             temp+=p;
  28.             if(temp>=k){
  29.                 for(int j = 0;j<=k;j++){
  30.                     saida+=vetor[j]*pow(i, j);
  31.                 }
  32.                 break;
  33.             }
  34.         }
  35.         cout<<saida<<endl;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment