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 题目链接 ...
随机推荐
- etcd节点扩容至两个节点
本篇已经安装了单个etcd,然后进行扩容etcd节点至2个,安装单节点请参照:https://www.cnblogs.com/effortsing/p/10295261.html 实验架构 test1 ...
- What is an Activation object in JavaScript ?
********************* from Professional JavaScript for Web Development Execution Context And Scope T ...
- js移动端滑动效果
移动端触屏滑动的效果其实就是图片轮播,在PC的页面上很好实现,绑定click和mouseover等事件来完成.但是在移动设备上,要实现这种轮播的效果,就需要用到核心的touch事件.处理touch事件 ...
- 大觅网07day
分布式日志环境的构建(ELK+Kafka) 主要是搭建分布式日志环境,由ELK+Kafka实现,分为以下四步实现: 一.Elasticsearch环境的搭建和测试 1.删除已经存在的ES容器和镜像,如 ...
- Centos6.5修改mysql登陆用户密码
1.修改mysql的登陆设置: vim /etc/my.cnf 并在[mysqld] 下面添加一句:skip-grant-tables=1 添加成功后保存退出. 2.重启mysql并修改密码 重启my ...
- 2D轮播图
目录结构 index.html <!DOCTYPE html><html lang="en"><head> <meta charset=& ...
- 简述Object(ActiveX)控件遮挡Dialog、select下拉框的解决办法
1.背景 最近在做项目的过程中,我们使用了Object控件,但是同时在上面写了一个select下拉框,因此每次点击下拉框的时候我们会发现,下拉框的部分内容被Object控件给遮挡了,调查研究后发现,我 ...
- xampp:windows找不到文件“-n”
转自:http://blog.csdn.net/soar92/article/details/72897789 安装xampp是总是出总是提示以下错误: ①安装xampp时提示windows找不到文件 ...
- day 02 while 循环 格式化输出 运算符 and or not - 编码的初识
while 循环 while 条件: 循环体 循环如何终止? 改变条件. flag = Truewhile flag: print('狼的诱惑') print('我们不一样') ...
- 在mac上配置cocos2d-x开发环境
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u012282115/article/details/24374539 一.首先下载cocos2d-x ...