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. ubuntu 中 搭建 C编程环境

    在 ubuntu 中 使用 快捷键 Ctrl + Alt + T 打开 终端 在终端输入 gcc 查看 有没有安装 gcc (c语言的编译器) ( 我这里是 已经 安装 好的 ) 进行 安装 gcc ...

  2. Codeforces Round #586 (Div. 1 + Div. 2) E. Tourism

    链接: https://codeforces.com/contest/1220/problem/E 题意: Alex decided to go on a touristic trip over th ...

  3. vue 01 练习

    1.有 红.黄.蓝 三个按钮,以及一个200x200矩形框box,点击不同的按钮,box的颜色会被切换为指定的颜色 <!DOCTYPE html> <html lang=" ...

  4. Verilog求余

    在实现三角函数时,考虑到函数的周期性,综量(自变量)需对周期做求余运算. 假设函数周期为T = 2^N,那么求余运算就是直接取该数的低N位,即: 以M位正数为例(符号位为0),reg [M-1:0] ...

  5. C#+Entity Frame work+MVC+Mysql+Apicloud共享汽车管理系统【论文】+Apicloud开发实例

    摘要: 共享汽车管理系统主要分为后台管理PC端和手机App端,后台管理可以对指定停车点.车辆基本信息.用户注册信息.用户订单信息.推送消息进行管理和维护,而手机app用户可以通过手机号进行短信注册,根 ...

  6. 51 Nod 1287 加农炮(单调队列思想+二分)

    1287 加农炮  题目来源: Codility 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题  收藏  关注 一个长度为M的正整数数组A,表示从左向右的地形高度 ...

  7. Casual Literary Notes

    写在前面的话: 人生中总会有一些惊喜,它会给予坚守的人们以奖励,提醒着人们,生命中不光是辛劳和付出. 很多收获,最后看来,往往都是因为当初的那一点坚持. -- 雷宇<现场> 1.18 上午 ...

  8. 洛谷 P1355 神秘大三角(计算几何基础)

    P1355 神秘大三角 题目提供者yeszy 标签 福建省历届夏令营 难度 普及/提高- 题目描述 判断一个点与已知三角形的位置关系. 输入输出格式 输入格式: 前三行:每行一个坐标,表示该三角形的三 ...

  9. 人脸检测之Haar-like,Adaboost,级联(cascade)

    最新版本整理完毕,见: http://face2ai.com/MachineLearning-Haar-like-Adaboost-cascade 0:写在前面的话           写在前面的牢骚 ...

  10. oracle数据库体系结构

    一.oracle数据库体系结构 基本组成: Oracle server:一般情况下是一个instance和一个database组成 一般:1个instance只能对应一个数据库. 特殊:1个数据库可以 ...