zoukankan      html  css  js  c++  java
  • codeforces goodbye 2018 C. New Year and the Sphere Transmission D. New Year and the Permutation Concatenation

    这两题都是打表找的规律,C题发现具有相同最大因子的数字所走的点是一样的,D题发现排列数和开头有几个相同的数字有关,所以用排列数公式算出有几个这样的开头再乘上这种开头的种类数就可以了

    C题

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll res[2010];
    int tot;
    int main()
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i*i<=n;i++)
        {
            if(n%i==0)
            {
                ll num=n/i;
                res[++tot]=num+1LL*(num-1)*num/2*i;
                if(i*i==n)
                   continue;
                ll tmp=n/i;
                num=n/tmp;
                res[++tot]=num+1LL*(num-1)*num/2*tmp;
            }
        }
        sort(res+1,res+tot+1);
        for(int i=1;i<=tot;i++)
        {
            if(res[i]!=res[i-1])
              printf("%lld ",res[i]);
        }
        printf("
    ");
    }

    D题

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll A[1000010];
    const ll MOD=998244353;
    int main()
    {
        int n;
        scanf("%d",&n);
        A[1]=1;
        for(int i=2;i<=n;i++)
        {
            A[i]=A[i-1]*i%MOD;
        }
        ll res=A[n];
        ll now=n;
        for(int i=1;i<=n-2;i++)
        {
            res+=(A[n-i]-1)*now;
            res%=MOD;
            now*=(n-i);
            now%=MOD;
        }
        printf("%lld
    ",res);
    }
  • 相关阅读:
    Intern Day16
    粉红
    开始还房贷!
    Sonnet-十四行诗
    CSS兼容大全
    TCL电视直播软件
    《Linux权威指南》阅读笔记(2)
    《Linux权威指南》阅读笔记(1)
    Linux crontab定时执行任务 命令格式与详细例子
    linux下find查找命令用法
  • 原文地址:https://www.cnblogs.com/lishengkangshidatiancai/p/10205339.html
Copyright © 2011-2022 走看看