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 }
  • 相关阅读:
    Codeforces Round #131 (Div. 2) E. Relay Race dp
    Codeforces Round #130 (Div. 2) C
    Codeforces Round #130 (Div. 2) A. Dubstep
    UVA 11858 Frosh Week 逆序对统计
    UVA 11149 Power of Matrix 快速幂
    UVA 12382 Grid of Lamps 贪心
    POJ 3614 Sunscreen 贪心
    Codeforces Round #238 (Div. 2) D. Toy Sum 暴搜
    Codeforces Round #227 (Div. 2) E. George and Cards 线段树+set
    Codeforces Round #327 (Div. 2) E. Three States
  • 原文地址:https://www.cnblogs.com/NaVi-Awson/p/8175894.html
Copyright © 2011-2022 走看看