Source Code
#include<bits/stdc++.h>
#define cin(vec) for(auto& i : vec) cin >> i
#define cout(vec) for(auto& i : vec) cout << i 
#define ll long long
#define author_mohamed cin.tie(0)->sync_with_stdio(0);cin.exceptions(cin.failbit);
#define ss short
#define umset unordered_multiset
#define uset unordered_set
#define fx(b)  fixed << setprecision(b)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vi vector
#define vis vector<string>
#define t   int t;cin >> t;while(t--)
#define vi vector
#define st string
#define mod  1000000007
#define mp   make_pair
using namespace std;
ll gcd(ll a, ll b) {if (a < b)swap(a, b);while (a != 0 && b != 0) {ll r = a % b;a = b;b = r;}return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
unsigned ll nCr(int n, int r) {if (r > n)return 0;r = max(r, n - r); unsigned ll ans = 1, div = 1, i = r + 1;while (i <= n) {ans *= i;i++;ans /= div;div++;}return ans;}
 unsigned ll npr(int n,int r){if(r>n)return 0;unsigned ll a=1,i=n-r+1; while(i<=n){a*=i;i++;}return a;}
int xc[4] = {-1, 1, 0, 0};
int yc[4] = {0, 0, -1, 1};
 


void solve(){
    ll n,ans=0;cin>>n;
    ll c=0;
    while(n>=1){
        ans+=nCr(n,c);
        ans%=mod;
        c++;
        n--;
    }
    cout<<ans<<'\n';
}
int main()
{
author_mohamed
//freopen("in.txt", "r", stdin);
 //freopen("out.txt", "w", stdout);
 t{
    solve();
 }
 return 0;
}
Copy
Study Schedule mohamed
GNU G++17
2066 ms
368 KB
Time Limit Exceeded