【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;
} /*
写完之后,明确每一步的作用
*/

最新文章

  1. 利用epoll写一个&quot;迷你&quot;的网络事件库
  2. 无废话ExtJs 入门教程二[Hello World]
  3. 唐巧的iOS技术博客选摘
  4. 在ASP.NET MVC中使用Area
  5. java io操作常规
  6. java连接access数据库
  7. 51 nod 1006 最长公共子序列Lcs
  8. delete之后千万要记得将指针置空,即勿重复delete!!!
  9. SelectSingleNode和SelectNodes区别
  10. angular中实现jQuery的Document Ready
  11. jvm attach
  12. Python面向对象编程(一)
  13. echarts 支持svg格式
  14. Nodejs http-proxy代理实战应用
  15. shell 运算符章节笔记
  16. Oracle_异常
  17. 不偏移的天地图地图服务-ArcGIS版
  18. Docker Kubernetes Volume 网络数据卷
  19. API与软件架构-接口
  20. Codeforces Round #466 (Div. 2) Solution

热门文章

  1. 关于nth-of-type和nth-child的关系
  2. Metasploit的三种启动方式
  3. HDFS文件上传下载过程(详图)
  4. 为一个支持GPRS的硬件设备搭建一台高并发服务器用什么开发比较容易?
  5. 查询SqlServer最近执行过的Sql
  6. POJ 2251 Dungeon Master【BFS】
  7. Ubuntu14.04下tensorflow安装
  8. NOIP2017普及组题
  9. 七 HBase表结构设计
  10. UITextView自己定义键盘和系统键盘