diff --git a/DALTSUM.cpp b/DALTSUM.cpp new file mode 100644 index 0000000..d3a6b2d --- /dev/null +++ b/DALTSUM.cpp @@ -0,0 +1,37 @@ +// Problem : DALTSUM from SPOJ + +#include +#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>x; + if(i==0){ + v = x; + } + else{ + v = max(v,x); + } + } + v = ((v%MOD)+MOD)%MOD; + cout<<(v*power(n-1))%MOD; + return 0; +} \ No newline at end of file