链接:

https://vjudge.net/problem/Gym-100923I

题意:

We don't know how Por Costel the pig arrived at FMI's dance party. All we know is that he did.

The dance floor is hot because Por Costel broke the air conditioner. On the dance floor, the boys and girls are clumsy. There are boys at the party. The -th one has clumsiness level . There ale also girls at the party. The -th girl has clumsiness level as well. Por Costel finds that a pair of a boy and a girl can dance only if the product of their clumsiness levels is at most , i.e. girl clumsiness level * boy clumsiness level . Por Costel thinks that a sack of oats with a slice of leek could make a better dancing pair than the people at this party. Nonetheless, he would like to find out how many pairs (boy, girl) can dance. The input will contain the number representing the number of tests. The next lines will contain the number .

思路;

因为是男和女都能选,优化到sqrt(n),每次n/i算两次,但是前i个用过了,最后在加上当前对应的.

代码:

#include <iostream>
#include <memory.h>
#include <string>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <queue>
#include <math.h>
#include <cstdio>
#include <set>
#include <iterator>
#include <cstring>
using namespace std; typedef long long LL;
const int MAXN = 1e6+10;
const int MOD = 1e9+7; LL n; int main()
{
freopen("perechi3.in","r",stdin);
freopen("perechi3.out","w",stdout);
int t;
cin >> t;
while (t--)
{
LL res = 0;
cin >> n;
for (LL i = 1;i*i <= n;i++)
res += 2*(n/i-i)+1;
cout << res << endl;
} return 0;
}

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 - 100923I】Por Costel and the Pairs(思维题)

    Por Costel and the Pairs Descriptions 有T组测试样例 有n个男的,n个女的,第i个人都有为当前一个大小为i的懒惰值,当一男一女懒惰值的乘积<=n他们就就可以 ...

  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. 【Gym - 100923A】Por Costel and Azerah(思维水题)

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

随机推荐

  1. ubuntu中写sh脚本

    批量执行命令 https://jingyan.baidu.com/article/3052f5a121c8ac97f21f8661.html 批量执行脚本也是可行的! 如,main.sh内写   sh ...

  2. Day03:运算符和表达式 / 分支结构

    Java 运算符 计算机的最基本用途之一就是执行数学运算,作为一门计算机语言,Java也提供了一套丰富的运算符来操纵变量.我们可以把运算符分成以下几组: 算术运算符 关系运算符 位运算符 字符串运算符 ...

  3. Python基础知识思维导图|自学Python指南

    微信公众号[软件测试大本营]回复"python",获取50本python精华电子书. 测试/开发知识干货,互联网职场,程序员成长崛起,终身学习. 现在最火的编程语言是什么?答案就是 ...

  4. 磁盘的分区和挂载(mount)

    一.挂载问题的引入 我们大多数人用惯了windos系统,对linux系统中磁盘的管理就先入为主,不太好理解挂载这一动作.在linux系统中添加一块新磁盘后,要进行分区.格式化(分配文件系统).挂载.当 ...

  5. 【VS开发】【图像处理】V4L2 pixel format

    目录(?)[-] v4l2_pix_format定义 2 具体Pixel Format定义 1. v4l2_pix_format定义 [cpp] view plain copy /* *  V I D ...

  6. selenium—用NoSuchElementException异常判断页面元素是否存在

    一.知识补充 1.find_element的一种使用方法: find_element(by=方法,value=值) 例如: find_element(by="id",value=& ...

  7. 【Linux 网络编程】滑动窗口协议

    <1>通知接受窗口(rwnd): 预防应用程序发送的数据超过对方的缓冲区.接收方使用的流量控制<2>拥塞窗口(cwnd): 预防应用程序发送的数据超过网络所承受的能力.发送方使 ...

  8. [转帖]Ubuntu 对应内核版本

    带有相应Linux内核版本的Ubuntu版本列表 https://www.helplib.com/ubuntu/article_155943   问题: 是否有带有默认对应的Linux内核版本的Ubu ...

  9. 小记-------linux scp 远程拷贝命令

    //phoenix-4.10.0-HBase-1.2-server.jar  要拷贝的文件或文件夹 //root  当前用户   //192.148.21.1 远程机器路径, 也可以是域名. // $ ...

  10. mysql 官网下载太慢了,来这里!!!

    RT.去官网下载mysql简直是折磨,太慢了!!! 但我还是坚持住了,下载下来了,我自己下载的是 MAC 5.7.27版本,网盘分享下,有需要的自提吧: 链接:https://pan.baidu.co ...