/ SeriousOJ /

Record Detail

Compile Error

foo.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.

Code

#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<utility>
#define ll long long
#define nl '\n'
using namespace std;
 const ll N=1e9+7;
ll ncr(ll n, ll r) {
    if (r > n) return 0; 
    if (r == 0 || n == r) return 1;  
    ll mul = 1;
    for (int i = 0; i < r; i++) {
        mul = mul * (n - i) / (i + 1); 
    }
    return mul;
}


int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
    ll n,q;
    cin>>n>>q;
    ll a[n];
    ll pre[n];
   for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i == 0) {
            pre[i] = (a[i] % 2 == 1) ? 1 : 0;
        } else {
            pre[i] = pre[i - 1] + (a[i] % 2 == 1 ? 1 : 0);
        }
    }
    while(q-- ){
    ll x,y,z;
    cin>>x>>y>>z;
    y--;z--;
    ll odd=pre[z]-pre[y];
        if(a[x]%2==1){
            odd++;
        }
       
     ll even=z-y+1-odd;
    if(x==0){
        ll combination_odd=0;
        for(int i=2;i<= odd ;i+=2){
             combination_odd+=ncr(odd,i)%N;
        }
        ll combination_even=0;
        for(int i=1;i<=even ;i++){
             combination_even+=ncr(even,i)%N;
        }
        ll ans=(combination_even+combination_odd+combination_even*combination_odd)%N;
        cout<<ans<<nl;
    }
    else{
          ll combination_odd=0;
        for(int i=1;i<= odd ;i+=2){
             combination_odd+=ncr(odd,i)%N;
           
        }
        ll combination_even=0;
        for(int i=1;i<=even ;i++){
             combination_even+=ncr(even,i)%N;
        }
       
        ll ans=combination_odd+combination_even*combination_odd;
        cout<<ans%N<<nl;
    }
    
    
    
    }


}

Information

Submit By
Type
Submission
Problem
P1033 Lyra and the Secrets of the Grand Library
Language
C99 (GCC 13.2.0)
Submit At
2024-11-02 15:55:08
Judged At
2024-11-11 02:34:15
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes