fork download
  1. #include<bits/stdc++.h>
  2. #define mariom ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(0)
  3. #define endl "\n"
  4. #define ll long long
  5. #define pi 3.14159265358979323846
  6. using namespace std;
  7. bool pr(int n){
  8. if(n<=1)
  9. return false;
  10. for(int i=2;i*i<=n;i++){
  11. if(n%i==0)
  12. return false;
  13. }
  14. return true;
  15. }
  16. /*ll fact(ll n ){
  17.   ll m=1e9+7;
  18. if (n<=1)
  19.   return 1;
  20.   else
  21.   return (n*fact(n-1))%m;
  22. }*/
  23. ll nCr(ll n, ll r) {
  24. ll m=1e9+7;
  25. if (r > n)
  26. return 0;
  27. if (r == 0 || r == n)
  28. return 1;
  29. return (nCr(n - 1, r - 1) + nCr(n - 1, r));
  30. }
  31.  
  32. int main() {
  33. mariom;
  34. int t;
  35. cin>>t;
  36. ll m=1e9+7;
  37. while(t--){
  38. ll n ;
  39. cin>>n;
  40. ll c=0;
  41. vector<ll>v;
  42. for(int i=2;i<=n;i++){
  43. if(pr(i)==true)
  44. v.push_back(i);
  45. }
  46. for(int i=v[0];i<=v[v.size()-1];i++){
  47. c+=(nCr(n,i));
  48. }
  49. cout<<c%m<<endl;
  50. }
  51. return 0;
  52. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty