fork download
  1. #include <iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. #define MOD 1000000007;
  6.  
  7. long long int power(int a,int b)
  8. {
  9. if(b==0)
  10. return 1;
  11. if(b==1)
  12. return a;
  13. if(b%2==0)
  14. return power(pow(a,2),b/2)%MOD;
  15. if(b%2!=0)
  16. return (a * power(pow(a,2),(b-1)/2))%MOD;
  17. }
  18.  
  19.  
  20. int main()
  21. {
  22. int t,n,i;
  23. long long int cr,ans=0;
  24.  
  25. int *a,*dp;
  26. cin>>t;
  27. while(t--)
  28. {
  29. cin>>n;
  30. a=new int[n];
  31. dp=new int[n];
  32. for(i=0;i<n;i++)
  33. cin>>a[i];
  34.  
  35. for(int diff=-100;diff<=100;diff++)
  36. {
  37. int sum[101]={0};
  38.  
  39. cr=0;
  40.  
  41. for(i=0;i<n;i++)
  42. {
  43. if(a[i]-diff>=1 && a[i]-diff<=100)
  44. {
  45.  
  46. dp[i]=(sum[a[i]-diff]+1)%MOD;
  47. sum[a[i]]=(sum[a[i]]+dp[i])%MOD;
  48. cr=(cr+dp[i])%MOD;
  49.  
  50. }
  51. else
  52. {
  53. dp[i]=1;
  54. sum[a[i]]=(sum[a[i]]+dp[i])%MOD;;
  55. cr=(cr+dp[i])%MOD;
  56.  
  57. }
  58.  
  59.  
  60. }
  61. ans=(ans+cr-n)%MOD;
  62.  
  63.  
  64.  
  65. }
  66. ans=(ans+n)%MOD;
  67.  
  68. ans=(power(2,n)-1-ans+MOD)%MOD;
  69. cout<<ans<<endl;
  70.  
  71.  
  72.  
  73. }
  74. return 0;
  75. }
Compilation error #stdin compilation error #stdout 0s 2864KB
stdin
1
100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
compilation info
prog.cpp: In function 'int main()':
prog.cpp:68: error: expected `)' before ';' token
prog.cpp:68: error: expected primary-expression before ')' token
prog.cpp:68: error: expected `;' before ')' token
stdout
Standard output is empty