zoukankan      html  css  js  c++  java
  • 洛谷 P2260 [清华集训2012]模积和 || bzoj2956

    https://www.lydsy.com/JudgeOnline/problem.php?id=2956

    https://www.luogu.org/problemnew/show/P2260

    暴力推式子即可

     1 #include<cstdio>
     2 #include<algorithm>
     3 #include<cstring>
     4 #include<vector>
     5 using namespace std;
     6 #define fi first
     7 #define se second
     8 #define mp make_pair
     9 #define pb push_back
    10 typedef long long ll;
    11 typedef unsigned long long ull;
    12 typedef pair<int,int> pii;
    13 const ll md=19940417;
    14 ll n,m,ans,a1,a2;
    15 ll Mod(ll x,ll md=md)
    16 {
    17     if(x>=0)    return x%md;
    18     else if(x%md==0)    return 0;
    19     else    return md+x%md;
    20 }
    21 ll calc(ll x)
    22 {
    23     return (x)*(x+1)%md*(2*x+1)%md*3323403%md;
    24 }
    25 int main()
    26 {
    27     ll i,j;
    28     scanf("%lld%lld",&n,&m);
    29     if(n>m)    swap(n,m);
    30 
    31 
    32 //    {
    33 //        ll ams=0;
    34 //        for(ll i=1;i<=n;i++)
    35 //            for(ll j=1;j<=m;j++)
    36 //                if(i!=j)
    37 //                ams=Mod(ams+(n-n/i*i)*(m-m/j*j));
    38 //        printf("%lld",ams);
    39 //        return 0;
    40 //    }
    41 
    42 
    43     for(i=1;i<=n;i=j+1)
    44     {
    45         j=n/(n/i);
    46         a1=Mod(a1+Mod((i+j)*(j-i+1)/2)*(n/i));
    47     }
    48     for(i=1;i<=m;i=j+1)
    49     {
    50         j=m/(m/i);
    51         a2=Mod(a2+Mod((i+j)*(j-i+1)/2)*(m/i));
    52     }
    53     //printf("a%lld %lld
    ",a1,a2);
    54 
    55     ans=Mod(ans+n*n%md*m%md*m%md);
    56     ans=Mod(ans-n*n%md*a2%md);
    57     ans=Mod(ans-m*m%md*a1%md);
    58     ans=Mod(ans+a1*a2%md);
    59 
    60     ans=Mod(ans-n*n%md*m%md);
    61     {
    62         ll t=0;
    63         for(i=1;i<=n;i=j+1)
    64         {
    65             j=min(n,m/(m/i));
    66             t=Mod(t+Mod((i+j)*(j-i+1)/2)*(m/i));
    67         }
    68         ans=Mod(ans+n*t%md);
    69     }
    70     ans=Mod(ans+m*a1%md);
    71     {
    72         ll t=0;
    73         for(i=1;i<=n;i=j+1)
    74         {
    75             j=min(n/(n/i),m/(m/i));
    76             t=Mod(t+Mod(calc(j)-calc(i-1))*(n/i)%md*(m/i));
    77         }
    78         //printf("t%lld
    ",t);
    79         ans=Mod(ans-t);
    80     }
    81 
    82     printf("%lld",ans);
    83     return 0;
    84 }
  • 相关阅读:
    vue组件的通信
    vue基础
    vue项目总结
    路由(4)传参
    路由(3)
    第一次作业
    JAVA-2.0-homework
    JAVA-2.0-上机
    JAVA-1.9-homework
    JAVA-1.9-上机
  • 原文地址:https://www.cnblogs.com/hehe54321/p/9396444.html
Copyright © 2011-2022 走看看