• 【Gym


    Por Costel and the Pairs

    Descriptions

    有T组测试样例

    有n个男的,n个女的,第i个人都有为当前一个大小为i的懒惰值,当一男一女懒惰值的乘积<=n他们就就可以一起跳舞,请问有多少种组合可能;

    Example

    Input
    11
    1
    4
    5
    10
    100
    99
    16
    64
    49
    50
    48
    Output
    1
    8
    10
    27
    482
    473
    50
    280
    201
    207
    198
    题目链接
     
    求n/1+n/2+...+n/n,除法都是整除,但是这接这样写会超时
    换个思路
    第i个男人可以和前n/i个女人跳舞,女的也是这样,会有i个重复,但会多减一个坐标相同的,加上就好
    2*(n/i-i)+1要不小于0,因为人数不可能为负数
    即n/i-i>=0  解得i*i<=n
    AC代码
    #include <iostream>
    #include <cstdio>
    #include <fstream>
    #include <algorithm>
    #include <cmath>
    #include <deque>
    #include <vector>
    #include <queue>
    #include <string>
    #include <cstring>
    #include <map>
    #include <stack>
    #include <set>
    #include <sstream>
    #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
    #define Mod 1000000007
    #define eps 1e-6
    #define ll long long
    #define INF 0x3f3f3f3f
    #define MEM(x,y) memset(x,y,sizeof(x))
    #define Maxn 1000010
    using namespace std;
    ll T,n;
    int main()
    {
        freopen("perechi3.in","r",stdin);
        freopen("perechi3.out","w",stdout);
        cin>>T;
        while(T--)
        {
            cin>>n;
            ll ans=0;
            for(int i=1;i*i<=n;i++)
            {
                ans+=2*(n/i-i)+1;
            }
            cout<<ans<<endl;
        }
        return 0;
    }
  • 相关阅读:
    SNP/单核苷酸多态性分析
    非链特异性转录组测序
    什么是转录因子?
    MEME(Motif-based sequence analysis tools)使用说明
    DNA binding motif比对算法
    序列比对那点事儿
    DNA motif 搜索算法总结
    Bioconductor简介
    什么是RNA-Seq (RNA Sequencing)
    TPM、read counts、RPKM/FPKM你选对了吗?
  • 原文地址:https://www.cnblogs.com/sky-stars/p/11229289.html
Copyright © 2020-2023  润新知