fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. typedef long long ll;
  5. long long fun(long long s,long long M)
  6. {
  7. //s*(1+s)*(1+2*s)*(-1+3*s+3*s^2)/30
  8. // s= 30t + y
  9. ll sM,c2,c3,c90,c6;
  10. ll y = s%30 , sM = s%M ,c2=2 , c3=3,c90=90, c6=6;
  11. ll t = ((s-y)/30)%M;
  12. ll last = ( c3*sM*sM + c3*sM -1 )%M;
  13. ll last_two = ((c2*sM + 1) * last )%M;
  14. return (t*(sM+1)*last_two + t*y*last_two + c2*t*y*(y+1)*last + y*(y+1)*(c2*y+1)*(c90*t*t + c6*t*y + c3*t) + (y*(y+1)*(c2*y+1)*(c3*y*y+c3*y-1))/30 )%M;
  15. }
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. int main() {
  23.  
  24. long long t,n,m,i,s,x,y,ans;
  25. scanf("%lld",&t);
  26. while(t--)
  27. {ans=0;
  28. scanf("%lld",&n,&m);
  29. s=sqrt(n);
  30.  
  31. for(i=1;i<=s;i++)
  32. {
  33. ans=(ans+((i*i*i)%m)*((i*(n/i))%m))%m;
  34. }
  35. for(i=n/s;i>1;i--)
  36. {
  37. x=n/i;
  38. y=n/(i-1);
  39. ans=(ans+(i-1)*(fun(y,m)-fun(x,m)))%m;
  40. }
  41.  
  42. if(ans<0)
  43. ans+=m;
  44.  
  45. printf("%lld\n",ans);
  46.  
  47. }
  48.  
  49.  
  50.  
  51. return 0;
  52.  
  53. }
  54.  
  55.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
4
1000
compilation info
prog.cpp: In function ‘long long int fun(long long int, long long int)’:
prog.cpp:10:16: error: redeclaration of ‘ll sM’
  ll y = s%30 , sM = s%M ,c2=2 , c3=3,c90=90, c6=6;
                ^
prog.cpp:9:5: error: ‘ll sM’ previously declared here
  ll sM,c2,c3,c90,c6;
     ^
prog.cpp:10:26: error: redeclaration of ‘ll c2’
  ll y = s%30 , sM = s%M ,c2=2 , c3=3,c90=90, c6=6;
                          ^
prog.cpp:9:8: error: ‘ll c2’ previously declared here
  ll sM,c2,c3,c90,c6;
        ^
prog.cpp:10:33: error: redeclaration of ‘ll c3’
  ll y = s%30 , sM = s%M ,c2=2 , c3=3,c90=90, c6=6;
                                 ^
prog.cpp:9:11: error: ‘ll c3’ previously declared here
  ll sM,c2,c3,c90,c6;
           ^
prog.cpp:10:38: error: redeclaration of ‘ll c90’
  ll y = s%30 , sM = s%M ,c2=2 , c3=3,c90=90, c6=6;
                                      ^
prog.cpp:9:14: error: ‘ll c90’ previously declared here
  ll sM,c2,c3,c90,c6;
              ^
prog.cpp:10:46: error: redeclaration of ‘ll c6’
  ll y = s%30 , sM = s%M ,c2=2 , c3=3,c90=90, c6=6;
                                              ^
prog.cpp:9:18: error: ‘ll c6’ previously declared here
  ll sM,c2,c3,c90,c6;
                  ^
prog.cpp: In function ‘int main()’:
prog.cpp:28:21: warning: too many arguments for format [-Wformat-extra-args]
   scanf("%lld",&n,&m);
                     ^
stdout
Standard output is empty