【CS Round #37 (Div. 2 only) B】Group Split
2024-10-01 16:37:38
【Link】:https://csacademy.com/contest/round-37/task/group-split/
【Description】
让你把一个数分成两个数a、b的和;
(a,b>0)
使得b是a的倍数
问分法个数
【Solution】
设b=x∗a;
则
a+x∗a=n
a∗(x+1)=n
这里可以看出来,a必须是n的因子;
再把x分离出来
x=na−1
而x>=1
则
a<=n2
这里n/2实际上就是第二大的因子
所以,这里等价于a< n
于是乎,问题转化成
求小于n的因子个数
【NumberOf WA】
0
【Reviw】
数学推导要认真点。
【Code】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
int n;
int main(){
//Open();
//Close();
scanf("%d",&n);
int len = sqrt(n);
int ans = 0;
rep1(i,1,len)
if (n%i==0){
ans++;
int t = n/i;
if (t!=i && t < n)
ans++;
}
printf("%d\n",ans);
return 0;
}
/*
写完之后,明确每一步的作用
*/
最新文章
- 利用epoll写一个";迷你";的网络事件库
- 无废话ExtJs 入门教程二[Hello World]
- 唐巧的iOS技术博客选摘
- 在ASP.NET MVC中使用Area
- java io操作常规
- java连接access数据库
- 51 nod 1006 最长公共子序列Lcs
- delete之后千万要记得将指针置空,即勿重复delete!!!
- SelectSingleNode和SelectNodes区别
- angular中实现jQuery的Document Ready
- jvm attach
- Python面向对象编程(一)
- echarts 支持svg格式
- Nodejs http-proxy代理实战应用
- shell 运算符章节笔记
- Oracle_异常
- 不偏移的天地图地图服务-ArcGIS版
- Docker Kubernetes Volume 网络数据卷
- API与软件架构-接口
- Codeforces Round #466 (Div. 2) Solution