Xuejun faithful team tournament fun network D. fight against SARS fight

D. fight against SARS fight

Time limit: \ (2000ms \)
space constraints: \ (512MB \)

Title Description

Since the new crown outbreak, the virus continues to spread spread, and humans are constantly taken various measures to curb the spread of the virus. So we can build a mathematical model to fight this fight against SARS, we will continue to spread the virus and humans continue to take steps to abstract a game both sides turn action. We believe the human virus with each round action can be selected as a positive integer value to evaluate the action. However, aspects of restriction for the sum of all the values of both actions must be equal to a number \ (m \) , and the value of each action must not exceed the value of the other actions of the last round. For humans, to curb the epidemic, it should be the last action of the party, that is, after a particular action this side, the value of the sum of the action \ (m \) happens to be consumed.

Assuming that humans act first and then we just bang consumed all \ (m \) point action value, will be able to overcome the virus. However, in the beginning stages of the epidemic due to not recognize the severity, often the most difficult to carry out large-scale operations. For this reason, we let \ (h_m \) represents the sum of the action value \ (m \) in the case of humans (that is, first actors) first act the minimum value to be much action in order to ensure that they win .

For statistical needs, a scientist credited \ (F_i = \ sum_ {m | i} h_m \) , and wanted to know \ (\ sum_ {i = 1} ^ nf_i \) . Convenience sake \ (998,244,353 \) modulo. Can you help me?

Input Format

A first input line number \ (n-\) .

Output Format

Line a number representing the answer.

Sample input

\(3\)

Sample Output

\(6\)

Restrictions and conventions

The title uses subtasks in the form of evaluation.

No subtasks \(n<=\) Scores
\(1\) \(3\) \(1\)
\(2\) \(1000\) \(9\)
\(3\) \(10^5\) \(31\)
\(4\) \(10^{11}\) \(28\)
\(5\) \(5*10^{13}\) \(26\)
\(6\) \(10^{15}\) \(5\)

For all data, satisfies \ (. 1 <= n-<= 10 ^ {15} \) .

Thinking

We can calculate Law \ (h_m = lowbit (m) \)
\ (S (n-) = \ sum_ {I =. 1} ^ n-\ sum_ {m | I} h_m = \ sum_ {m =. 1} ^ nh_m \ lfloor frac {n} {m} \
rfloor \) \ then we can calculate \ (h_m \) before \ (n-\) entry, and then do the block, but this can only be to the task 4

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 998244353;
LL work(LL n)
{
    if(n==1||n==0)return n;
    LL ans=2*work(n>>1)+n/2;
    if(n%2)ans++;
    return ans%mod;
}
int main()
{
    LL n;
    scanf("%lld",&n);
    LL ans=0;
    for(LL l=1,r;l<=n;l=r+1)
    {
        r=n/(n/l);
        ans=(ans+n/l*(work(r)-work(l-1))%mod)%mod;
    }
    printf("%lld\n",(ans+mod)%mod);
    return 0;
}

We consider the enumeration \ (h_m \) values, and its contribution to unified computing.
\ (h_m = lowbit (m) = 2 ^ k \) contribution: \ (2 ^ K (\ FRAC {n-} {2 ^ K} + \ FRAC {n-} {2 * 2 ^ K} + \ FRAC n-*}. 3 {{^ 2 + ... K}) \) , because this part of the rear overcharged \ (2 ^ {k + 1 }, 2 ^ {k + 2}, ... \) contribution Therefore, when the rear portion of the operator to lose had been considered, so just multiply \ ((2 ^ k-2
^ {k-1}) \) order \ (g (n) = \ sum_ {i = . 1} ^ n-\ lfloor \ FRAC {n-} {I} \ rfloor \)
\ (S (n-) = G (n-) + \ sum_ {K =. 1} (2 ^ K-2 ^ {K-. 1}) g (\ frac {n} { 2 ^ k}) \)

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 998244353;
LL g(LL n)
{
    /* //95分,最后一个任务过不了
    LL res=0;
    for(LL l=1,r;l<=n;l=r+1)
    {
        r=n/(n/l);
        res=(res+(r-l+1)%mod*(n/l)%mod)%mod;
    }
    return res;*/
    LL res=0;
    LL p=sqrt(n);
    for(LL i=1;i<=p;i++)res=(res+n/i)%mod;
    return (2*res-p*p)%mod;
}
int main()
{
    LL n;
    scanf("%lld",&n);
    LL ans=g(n);
    for(LL i=1;(1LL<<i)<=n;i++)
        ans=(ans+(1LL<<(i-1))%mod*g(n/(1LL<<i)))%mod;
    printf("%lld\n",ans);
    return 0;
}

Guess you like

Origin www.cnblogs.com/HooYing/p/12652627.html