Skip to content

Commit

Permalink
Problem DALTSUM from SPOJ
Browse files Browse the repository at this point in the history
  • Loading branch information
mani1996 committed Oct 17, 2016
1 parent e76a249 commit 2951b96
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions DALTSUM.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Problem : DALTSUM from SPOJ

#include <bits/stdc++.h>
#define ll long long
using namespace std;

#define MOD 1000000007

ll power(ll n){
ll res = 1,temp = 2;
while(n){
if(n%2)res*=temp;
n/=2;
temp*=temp;
if(res>=MOD)res%=MOD;
if(temp>=MOD)temp%=MOD;
}
return res;
}

int main(){
int n,i;
cin>>n;
ll v,x;
for(i=0;i<n;i++){
cin>>x;
if(i==0){
v = x;
}
else{
v = max(v,x);
}
}
v = ((v%MOD)+MOD)%MOD;
cout<<(v*power(n-1))%MOD;
return 0;
}

0 comments on commit 2951b96

Please sign in to comment.