Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ff first
- #define ss second
- #define ll long long
- #define pb push_back
- #define mp make_pair
- #define pii pair<int,int>
- #define vi vector<int>
- #define mii map<int,int>
- #define pqb priority_queue<int>
- #define pqs priority_queue<int,vi,greater<int> >
- #define setbits(x) __builtin_popcountll(x)
- #define zrobits(x) __builtin_ctzll(x)
- #define mod 1000000007
- #define inf 1e18
- #define ps(x, y) fixed<<setprecision(y)<<x
- #define mk(arr, n, type) type *arr=new type[n];
- #define w(x) int x; cin>>x; while(x--)
- #define pw(b, p) pow(b,p) + 0.1
- void fastIO() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- }
- int main() {
- fastIO();
- int n,l,r;
- cin>>n>>l>>r;
- vector<vi> dp(n,vi(3,0));
- for(int i=l;i<=r;i++){
- dp[0][i%3]++;
- dp[1][i%3]++;
- }
- int times=r-l+1;
- for(int i=2;i<n;i++){
- dp[i][0]=((ll)times*dp[i-1][0])%mod;
- dp[i][1]=((ll)times*dp[i-1][2])%mod;
- dp[i][2]=((ll)times*dp[i-1][1])%mod;
- }
- ll sum=((ll)((ll)dp[n-1][0]+dp[n-1][1])%mod+dp[n-1][2])%mod;
- cout<<sum<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement