Gym-100923I-Por Costel and the Pairs(数学,思维)
链接:
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(数学,思维)的更多相关文章
- 【数形结合】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 ...
- 【Gym - 100923I】Por Costel and the Pairs(思维题)
Por Costel and the Pairs Descriptions 有T组测试样例 有n个男的,n个女的,第i个人都有为当前一个大小为i的懒惰值,当一男一女懒惰值的乘积<=n他们就就可以 ...
- 【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 ...
- 【找规律】Gym - 100923L - Por Costel and the Semipalindromes
semipal.in / semipal.out Por Costel the pig, our programmer in-training, has recently returned from ...
- 【分块打表】Gym - 100923K - Por Costel and the Firecracker
semipal.in / semipal.out Por Costel the pig, our programmer in-training, has recently returned from ...
- 【并查集】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 ...
- 【动态规划】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 ...
- 【带权并查集】Gym - 100923H - Por Costel and the Match
裸题. 看之前的模版讲解吧,这里不再赘述了. #include<cstdio> #include<cstring> using namespace std; int fa[10 ...
- 【Gym - 100923A】Por Costel and Azerah(思维水题)
Por Costel and Azerah Descriptions 给你n个数 问你,有多少个子序列 的和是偶数 Example Input 233 10 124 2 Output 33 题目链接 ...
随机推荐
- zabbix没有10051端口解决
1.查看zabbix的日志 [root@bogon ldap]# cat /tmp/zabbix_server.log '/var/lib/mysql/mysql.sock' (2) 2848:201 ...
- 学习Go语言(二)快速入门
作为一名学习过多种编程语言的“老码农”,学习一门新的语言不能像“新手”一样,要快速入门. 无论面向过程,还是面向对象的编程语言:静态语言,动态语言,一般都包括: 标识符.变量(常量).运算符.表达式. ...
- lua基础学习(六)
一.lua协同程序coroutine 1.什么是协同(coroutine)?Lua 协同程序(coroutine)与线程比较类似:拥有独立的堆栈,独立的局部变量,独立的指令指针,同时又与其它协同程序共 ...
- sqlplus语句示例
我们通常所说的DML.DDL.DCL语句都是sql*plus语句,它们执行完后,都可以保存在一个被称为sql buffer的内存区域中,并且只能保存一条最近执行的sql语句,我们可以对保存在sql b ...
- C语言作业08
问题 答案 这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 https://i.cnblogs.com/EditPosts.aspx?opt=1 我在这个课程的目标是 在学好C语言编程的 ...
- 索引之----mysql单列索引失效的情况
使用的索引名称: 1.隐式转换导致索引失效. 由于表字段定义为vachar类型,但在查询时把该字段作为number类型 以及where条件传给mysql. 2.对索引列进行任何操作(计算(+.-.*. ...
- Java 读取application.properties配置文件中配置
实际开发中若需要读取配置文件application.properties中的配置,代码如下.例:读取配置文件中name属性配置值: 代码如下: import org.springframework.c ...
- Laravel 程序优化
转载: Laravel 程序优化 说明 作为优秀的开发者,在日常编码中,应积极培养书写高执行效率代码的意识.不过项目运行效率是一个系统性工程,不应该只停留在代码层面上,有时更应该考虑整个项目架构,包括 ...
- python-day15(正式学习)
目录 递归 函数自我嵌套 调用 直接调用 间接调用 为什么要用递归呢 如何使用递归 内置函数 掌握 了解 面向对象方法 面向过程编程 注册 分层实现功能 递归 递归的本质就是函数调用自身,当然也会有一 ...
- http://www.pythontutor.com/visualize.html#mode=edit python在线检测代码
http://www.pythontutor.com/visualize.html#mode=edit