fork download
  1. #include<bits/stdc++.h>
  2. #define identity_imbalance 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. int main() {
  24. identity_imbalance;
  25. int t;
  26. cin>>t;
  27. ll m=1e9+7;
  28. while(t--){
  29. ll n ;
  30. cin>>n;
  31. ll c=0;
  32. vector<ll>v;
  33. for(int i=2;i<=n;i++){
  34. if(pr(i)==true)
  35. v.push_back(i);
  36. }
  37. for(int i=v[0];i<=v[v.size()-1];i++){
  38. if(n==i)
  39. (c++)%m;
  40. else c+=((fact(n)/(fact(i)*fact(n-i)))%m);
  41. }
  42. cout<<c%m<<endl;
  43. }
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5284KB
stdin
1
2
stdout
1