fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll int
  5. #define ull unsigned long long
  6. #define dd double
  7. #define ld long double
  8. #define sl(n) scanf("%lld", &n)
  9. #define si(n) scanf("%d", &n)
  10. #define sd(n) scanf("%lf", &n)
  11. #define pll pair <ll, ll>
  12. #define pii pair <int, int>
  13. #define mp make_pair
  14. #define pb push_back
  15. #define inf (1LL << 62)
  16. #define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
  17. #define for1(i, stop) for(ll i = 1; i <= stop; i++)
  18. #define for0(i, stop) for(ll i = 0; i < stop; i++)
  19. #define rep1(i, start) for(ll i = start; i >= 1; i--)
  20. #define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
  21. #define ms(n, i) memset(n, i, sizeof(n))
  22. #define casep(n) printf("Case %lld:", ++n)
  23. #define pn printf("\n")
  24. #define pf printf
  25. #define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  26.  
  27. const ll mod = 1e9 + 7, last = (1LL << 27);
  28. const ll block = 1e3;
  29. ll mult[42][last/block+10];
  30.  
  31. int main()
  32. {
  33. for(ll i = 2; i <= 40; i++) {
  34. long long mul = 1;
  35. for(ll j = i, k = 1; j <= last; j += i, k++) {
  36. mul = (mul * (1 + j)) % mod;
  37.  
  38. ll b = k / block;
  39. mult[i][b] = mul;
  40. }
  41. }
  42.  
  43. ll t, cs = 0;
  44. cin >> t;
  45. while(t--) {
  46. ll n, k;
  47. si(k), si(n);
  48.  
  49. ll c = n / k, b = c / block;
  50. long long mul = 1;
  51. if(b > 0) mul = mult[k][b-1];
  52.  
  53. for(ll i = b*block; i <= c; i++)
  54. mul = (mul * (1 + i*k)) % mod;
  55.  
  56. pf("Case %d: %lld\n", ++cs, mul);
  57. }
  58.  
  59. return 0;
  60. }
  61.  
  62.  
Success #stdin #stdout 1.64s 5548KB
stdin
Standard input is empty
stdout
Standard output is empty