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=;
for(int i=;i*i<=n;i++)
{
ans+=*(n/i-i)+;
}
cout<<ans<<endl;
}
return ;
}

【Gym - 100923I】Por Costel and the Pairs(思维题)的更多相关文章

  1. 【数形结合】Gym - 100923I - Por Costel and the Pairs

    perechi3.in / perechi3.out We don't know how Por Costel the pig arrived at FMI's dance party. All we ...

  2. 【Gym - 100923A】Por Costel and Azerah(思维水题)

    Por Costel and Azerah Descriptions 给你n个数 问你,有多少个子序列 的和是偶数 Example Input 233 10 124 2 Output 33 题目链接 ...

  3. 【Heap-dijkstra】Gym - 100923B - Por Costel and the Algorithm

    algoritm.in / algoritm.out Even though he isn't a student of computer science, Por Costel the pig ha ...

  4. 【找规律】Gym - 100923L - Por Costel and the Semipalindromes

    semipal.in / semipal.out Por Costel the pig, our programmer in-training, has recently returned from ...

  5. 【分块打表】Gym - 100923K - Por Costel and the Firecracker

    semipal.in / semipal.out Por Costel the pig, our programmer in-training, has recently returned from ...

  6. 【并查集】Gym - 100923H - Por Costel and the Match

    meciul.in / meciul.out Oberyn Martell and Gregor Clegane are dueling in a trial by combat. The fight ...

  7. 【动态规划】Gym - 100923A - Por Costel and Azerah

    azerah.in / azerah.out Por Costel the Pig has received a royal invitation to the palace of the Egg-E ...

  8. 【带权并查集】Gym - 100923H - Por Costel and the Match

    裸题. 看之前的模版讲解吧,这里不再赘述了. #include<cstdio> #include<cstring> using namespace std; int fa[10 ...

  9. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

随机推荐

  1. [TJOI2019]唱、跳、rap和篮球——容斥原理+生成函数

    先附一组sd图 然后放上原题链接 注意,队伍不同指的是喜好不同,不是人不同 先想到\(DP\),然后你会发现并没有什么优秀的状态设计,然后我们考虑容斥 设\(lim\)表示选的癌坤组数的上限,\(f_ ...

  2. BZOJ3037 创世纪[基环树DP]

    实际上基环树DP的名字是假的.. 这个限制关系可以看成每个点有一条出边,所以就是一个内向基环树森林. 找出每个基环树的环,然后对于树的部分,做DP,设状态选或不选为$f_{x,0/1}$,则 $f_{ ...

  3. 【洛谷P2480】古代猪文

    题目大意:求 \[ G^{\sum\limits_{d|N}\binom{n}{k}} mod\ \ 999911659 \] 题解:卢卡斯定理+中国剩余定理 利用卢卡斯定理求出指数和式对各个素模数的 ...

  4. 简单的理解 StringBuffer/StringBuilder/String 的区别

    StringBuffer/StringBuilder/String 的区别 这个三类之间主要的区别:运行速度,线程安全两个方面. 速度方面(快到慢): StringBuilder > Strin ...

  5. C# 通过Process.Start() 打开程序 置顶方法

    private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) { try { foreach ...

  6. @Import注解的作用

    在@Import注解的参数中可以填写类名,例如@Import(Abc.class),根据类Abc的不同类型,spring容器有以下四种处理方式: 1. 如果Abc类实现了ImportSelector接 ...

  7. 开源笔记软件Joplin

    Joplin is a free, open source note taking and to-do application, which can handle a large number of ...

  8. 有关 C# WebAPI知识

    1.[懒得安分博客总结的很全面] 2.关于基础类型作入参数的问题      参照此博客[ASP.NET WebAPI String 传值问题] 3.代码说明     using System; usi ...

  9. 请求返回模板定制,@RestControllerAdvice

  10. HDU 1512 Monkey King(左偏堆)

    爱争吵的猴子 ★★☆ 输入文件:monkeyk.in 输出文件:monkeyk.out 简单对比 时间限制:1 s 内存限制:128 MB [问题描述] 在一个森林里,住着N只好斗的猴子.开始,他们各 ...