zoukankan      html  css  js  c++  java
  • [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) ext{mod} 998244353$

    Input

    一行一个整数$n$

    Output

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

    Sample Input

    1

    Sample Output

    1

    Hint

    出题人沉迷文化课,无心造数据,满足数据是以10为首项,10为公比的等比数列

    题解

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

    显然:

    $$g(n) =
    egin{cases}
    sqrt n-1& ext{ n 是完全平方数}\
    lfloor sqrt n floor& ext{otherwise}
    end{cases}$$

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

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

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

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

     1 //It is made by Awson on 2018.1.2
     2 #include <set>
     3 #include <map>
     4 #include <cmath>
     5 #include <ctime>
     6 #include <queue>
     7 #include <stack>
     8 #include <cstdio>
     9 #include <string>
    10 #include <vector>
    11 #include <cstdlib>
    12 #include <cstring>
    13 #include <iostream>
    14 #include <algorithm>
    15 #define LL long long
    16 #define Max(a, b) ((a) > (b) ? (a) : (b))
    17 #define Min(a, b) ((a) < (b) ? (a) : (b))
    18 using namespace std;
    19 const LL MOD = 998244353;
    20 
    21 LL n;
    22 
    23 void work() {
    24     scanf("%lld", &n);
    25     n = n%MOD*n%MOD;
    26     printf("%lld
    ", n);
    27 }
    28 int main() {
    29     work();
    30     return 0;
    31 }
  • 相关阅读:
    Python爬虫连载1-urllib.request和chardet包使用方式
    Java连载69-接受输入、用数组模拟栈
    HTML连载61-焦点图、固定定位
    Java连载68-数组的拷贝、二维数组
    [Java] MVC
    [Java] JSP
    [Java] HTTP
    [设计模式] 设计模式课程(八)--抽象工厂模式
    [设计模式] 设计模式课程(七)--工厂模式
    [刷题] 75 Sort Colors
  • 原文地址:https://www.cnblogs.com/NaVi-Awson/p/8175894.html
Copyright © 2011-2022 走看看