[COGS 2877]老m凯的疑惑

Description

Margatroid退役之后沉迷文化课

这天,写完数学作业之后的他脑洞大开,决定出一道比NOIP2017 D1T1《小凯的疑惑math》还要好的题

题面是这样的

 

$$ f(n)=n^2\\ g(n)=\sum_{i=1}^{n^3}[f(i)<n]\\\\ k(n)=\sum_{i=1}^{n^3}[g(i)<n] $$

 

试求$k(n)\ \text{mod}\ 998244353$

Input

 

一行一个整数$n$

Output

 

一行一个整数$k(n)$

Sample Input

 

1

Sample Output

 

1

由题: $$g(n) = \sum_{i=1} [i^2 < n]$$

显然:

$$g(n) =\begin{cases}
\sqrt n-1& \text{ n 是完全平方数}\\
\lfloor \sqrt n \rfloor& \text{otherwise}
\end{cases}$$

构造等价函数: $$g(n) = \lfloor \sqrt {n-1} \rfloor$$

同理,由题: $$k(n) = \sum_{i=1} [\sqrt {i-1} < n]$$

因为 $n$ 是正整数,所以 $k(n)$ 等价于:

\begin{aligned}    

     k(n) &= \sum_{i=1} [i-1 < n^2]\\
     & = \sum_{i=1} [i <= n^2]\\
     & = n^2
\end{aligned}

转载自Navi:http://www.cnblogs.com/NaVi-Awson/p/8175894.html

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 using namespace std;
 6 long long Mod=998244353;
 7 long long n;
 8 int main()
 9 {
10   cin>>n;
11   cout<<((n%Mod)*(n%Mod))%Mod;
12 }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 

posted @ 2018-01-03 09:52  Z-Y-Y-S  阅读(221)  评论(0编辑  收藏  举报