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 题目链接 ...
随机推荐
- WPF DispatcherTimer GC回收
static DispatcherTimer GCTimer = new DispatcherTimer(); public static void BeginGC() { GCTimer.Inter ...
- Go语言入门 不错
Go入门 Go介绍 部落图鉴之Go:爹好还这么努力? 环境配置 安装 下载源码编译安装 下载相应平台的安装包安装 下载地址:https://golang.org/dl/ Linux上的apt-get, ...
- opencv2中访问像素的简单方法-自定义一个宏CV_MAT_ELEM2
利用Mat的step[0],step[1]访问像素的行列,自定义一个宏CV_MAT_ELEM2(src,dtype,y,x),src是待访问的Mat,dtype是src的数据类型(int,float, ...
- 使用 Blender* 重新拓扑 VR 和游戏素材
本文介绍如何将网格重新拓扑成一个整洁的低密度模型,然后 UV 解包该网格,以便将纹理贴添加至新模型.本文还将探讨如何使用免费工具,比如 Blender* 及其 Bsurface 插件,重新拓扑雕塑的 ...
- 华为HCNA乱学Round 2:路由基础
- 【Qt开发】QScrollArea添加布局后没有出现滚动条的解决方法
[Qt开发]QScrollArea添加布局后没有出现滚动条的解决方法 标签:[Qt开发] 说明:尝试利用滚动区域显示多张图片,为了能够动态地往滚动区域贴图,为滚动区域设置了布局,然后通过布局来添加wi ...
- Oracle中的=:
dept_code=:dCode =:在这里的意思是变量绑定
- Qt - 基于UDP的网络编程
UDP(用户数据报协议 User Data Protocol) 轻量级.不可靠.面向数据报.无连接 的传输层协议. 适用情况: 网络数据大多为短消息: 拥有大量客户端: 对数据安全无特殊要求: 网络 ...
- nginx配置本地域名反向代理实现本地多域名80访问
什么是反向代理? 代理:通过客户机的配置,实现让一台服务器代理客户机,客户的所有请求都交给代理服务器处理. 反向代理:用一台服务器,代理真实服务器,用户访问时,不再是访问真实服务器,而是代理服务器. ...
- Linux普通用户无法使用sudo
问题描述: jenkins执行发布脚本,因为使用的是jenkins用户,所以有些shell命令需要 sudo 来执行,导致报错. + sudo rm -rf /usr/share/nginx/html ...