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 题目链接 ...
随机推荐
- Kotlin 的 @JvmStatic 和 @JvmField 注解
这是关于 Java 静态方法和静态变量的一段代码: public class TestStatic { private int otherField = 0; public static final ...
- April.Util更新之权限
目录 前言 权限 中间层 小结 前言 在之前已经提到过,公用类库Util已经开源,目的一是为了简化开发的工作量,毕竟有些常规的功能类库重复率还是挺高的,二是为了一起探讨学习软件开发,用的人越多问题也就 ...
- 通过NGINX location实现一个域名访问多个项目
location ~ \.php$ { root /home/webroot; //此目录下有多个项目 project1 ,project2... fastcgi_pass $php_upstr ...
- ll按时间排序和查看目录下文件数
查询文件并以降序排列:ll -t 查询文件并以升序排列:ll -t | tac 查询目录下文件数:ll|wc -l
- String,StringBuffer,StringBulider 三者的区别
1.String 是字符串常量,StringBuffer 和StringBuilder 是字符串变量. 2.运行速度 StringBuilder > StringBuffer > Stri ...
- Windows下备份mysql
---恢复内容开始--- Windows下备份mysql 第一步 编写脚本 ::设置时间变量 set "Ymd=%date:~0,4%%date:~5,2%%date:~8,2%%time ...
- idea常用快捷键列表
在使用IntelliJ Idea的时候,使用快捷键是必不可少的.掌握一些常用的快捷键能大大提高我们的开发效率.有些快捷键可以熟练的使用,但是还有另外一些快捷键虽然很好用,但是由于因为没有形成使用习惯或 ...
- 【字符串大模拟】潜伏者—— NOIP2009原题
洛谷连接 就一道黄题没啥可以说的……就是要细心…… 学到了神奇的优化 ios::sync_with_stdio(false); cin优化,能跑的比scanf快!棒!(不过要开std) 这题真的还挺简 ...
- Luogu P2612 [ZJOI2012]波浪
题目 我们考虑从\(1\)到\(n\)把每个数放到序列里面去,以消掉绝对值. 在最后的序列中,如果\(i\)的某一边是序列的边界,那么\(i\)会产生\(0\)的贡献.如果\(i\)的某一边是一个比\ ...
- msql 事务
START TRANSACTION delete from t_emp delete from t_deptcommit START TRANSACTION delete from t ...