Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("O3,unroll-loops")
- #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
- #include "bits/stdc++.h"
- using namespace std;
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace __gnu_pbds;
- template<class key, class cmp = std::less<key>>
- using op_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
- #ifdef thunder
- #include "bug.h"
- #else
- #define bug(...)
- #endif
- #define ll long long
- #define lld double
- #define all(x) x.begin(), x.end()
- #define iceil(n, x) (((n) + (x) - 1) / (x))
- #define goog(tno) cout << "Case #" << tno <<": "
- const ll INF=2e18;
- const ll mod=1000000007;
- const ll maxn=1e6+10;
- template< ll mod >
- struct ModInt {
- ll x;
- ModInt() : x(0) {}
- ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
- ModInt &operator+=(const ModInt &p) {
- if((x += p.x) >= mod) x -= mod;
- return *this;
- }
- ModInt &operator-=(const ModInt &p) {
- if((x += mod - p.x) >= mod) x -= mod;
- return *this;
- }
- ModInt &operator*=(const ModInt &p) {
- x = (int) (1LL * x * p.x % mod);
- return *this;
- }
- ModInt &operator/=(const ModInt &p) {
- *this *= p.inverse();
- return *this;
- }
- ModInt operator-() const { return ModInt(-x); }
- ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
- ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
- ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
- ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
- bool operator<(const ModInt &p) const { return x < p.x; }
- bool operator>(const ModInt &p) const { return x > p.x; }
- bool operator==(const ModInt &p) const { return x == p.x; }
- bool operator!=(const ModInt &p) const { return x != p.x; }
- string to_str() { return to_string(x); }
- ModInt inverse() const {
- ll a = x, b = mod, u = 1, v = 0, t;
- while(b > 0) {
- t = a / b;
- swap(a -= t * b, b);
- swap(u -= t * v, v);
- }
- return ModInt(u);
- }
- ModInt pow(int64_t n) const {
- ModInt ret(1), mul(x);
- while(n > 0) {
- if(n & 1LL) ret *= mul;
- mul *= mul;
- n >>= 1LL;
- }
- return ret;
- }
- friend ostream &operator<<(ostream &os, const ModInt &p) {
- return os << p.x;
- }
- friend istream &operator>>(istream &is, ModInt &a) {
- int64_t t;
- is >> t;
- a = ModInt< mod >(t);
- return (is);
- }
- static ll get_mod() { return mod; }
- };
- using mint = ModInt< mod >;
- vector<ll> ok;
- vector<mint> pref;
- void solve(){
- ll l,r;
- cin>>l>>r;
- ll idx_l=upper_bound(all(ok),l)-ok.begin();
- ll idx_r=upper_bound(all(ok),r)-ok.begin();
- auto ok=[](ll n)->bool{
- ll x=cbrtl(n);
- if(x*x*x==n) return 1;
- return 0;
- };
- // if(l==r){
- // if(!ok(l)){
- // cout<<0<<'\n';
- // return;
- // }else{
- // cout<<l<<'\n';
- // }
- // return;
- // }
- bug(idx_l,idx_r);
- mint ans=pref[idx_r-1];
- if(ok(l)) idx_l--;
- ans-=pref[idx_l-1];
- cout<<ans<<'\n';
- }
- signed main(){
- ios_base::sync_with_stdio(false), cin.tie(nullptr);
- //freopen("input.txt","r",stdin);
- //freopen("output.txt","w",stdout);
- for(ll i=0;i<maxn;i++){
- ok.push_back(i*i*i);
- }
- // bug(ok);
- pref={ok[0]};
- for(ll i=1;i<maxn;i++){
- pref.push_back(pref.back()+ok[i]);
- }
- int t=1;
- cin>>t;
- for(int i=1;i<=t;i++){
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment