http://acm.hdu.edu.cn/showproblem.php?pid=6108

【题意】

给定进制P,求有多少个B满足P进制下,一个正整数是B的倍数的充分必要条件是每一位加起来的和是B的倍数。

【思路】

当时记起了离散数学课上学过为啥10进制下是3和9(因为10,3,9关于1同余),所以想到答案是n-1的因子个数

【AC】

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath> using namespace std; int n; int factor(int x)
{
int cnt=;
for(int i=;i*i<=x;i++)
{
if(x%i==)
{
if(i*i!=x)
{
cnt+=;
}
else
{
cnt+=;
}
}
}
return cnt;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
n-=;
int ans=factor(n);
printf("%d\n",ans);
}
return ;
}

最新文章

  1. css工具收集
  2. (Collection)350. Intersection of Two Arrays II
  3. Opencv CamShift+Kalman目标跟踪
  4. mysql一个事务中有DDL语句的binlog情况
  5. css基本知识
  6. Android之ORMLite实现数据持久化的简单使用
  7. oracle 导入导出数据
  8. mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
  9. American tour(If you have a chance)
  10. VC获取精确时间的做法
  11. HTML5线性图表 图表数据区域可着色
  12. libev实现分析
  13. iOS特性
  14. Python内置函数(26)——globals
  15. day 42 mycql 查询操作,重点中的重点
  16. FFT是个啥?
  17. sklearn linear_model,svm,tree,naive bayes,ensemble
  18. Django:视图views(一)
  19. 校园社交网站app
  20. 【Spring】Spring之事务处理

热门文章

  1. Android原生系统API自带dp、px、sp单位转换
  2. casting in C++
  3. JDBC优化策略总结
  4. 四次元新浪微博客户端Android源码
  5. 小知识~VS2012的xamarin加载失败解决
  6. DROP CONVERSION - 删除一个用户定义的编码转换
  7. Modal 高度 在里面css里写高 | iview
  8. QT_仅仅直接在构造函数中创建对象的不可行的原因
  9. Hibernate-03 关联映射
  10. JavaEE-04 数据源配置