【链接】http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=775&pid=1001


【题意】


在这里写题意

【题解】



abcd = a*p^3+b*p^2+c*p^1+d = a*(p^3-1)+b*(p^2-1)+c*(p-1)+a+b+c+d
则如果各位数上的和是m的倍数,且左边那一堆也是m的倍数的话,abcd就是m的倍数了;
且p^(x+1)-1=(p^x-1)*p+p-1
则如果p-1是m的倍数,p^2-1...都是m的倍数;
则整个abcd都是m的倍数.
所以只要是p-1的因子x就都可以了.
这样各位数的和只要是x的倍数,这个数就是x的倍数了.

【错的次数】


0

【反思】


在这了写反思

【代码】

#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 ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x+1)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#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 T,x; int main(){
//Open();
//Close();
ri(T);
while (T--){
int p;
ri(p);
int ans = 0;
rep1(i,1,(int) sqrt(p-1))
if ((p-1)%i==0){
if (i == ((p-1)/i))
ans++;
else
ans+=2;
}
oi(ans);
puts("");
}
return 0;
}

最新文章

  1. FreeBinary 格式说明
  2. javascript中矩形的碰撞检测---- 计算碰撞部分的面积
  3. Linux下MySQL忘记密码
  4. 5.19[bzoj树网的核]
  5. SPARQL1.1 101 Language and Jena support
  6. JS 代理模式
  7. 动态用javascript来修改单选框性别
  8. IE兼容HTML5
  9. 一种用css实现图片在父框中等比缩放并垂直居中的办法
  10. BZOJ 2946: [Poi2000]公共串( 后缀自动机 )
  11. oracle 表复制
  12. 201521123006 《Java程序设计》第7周学习总结
  13. 修改nopCommerce中的实体
  14. Qt中QComboBox中自定义界面使用stylesheet实现下拉按钮独立效果
  15. [SHOI2008]循环的债务
  16. java~springboot~目录索引
  17. cobbler一键批量安装系统
  18. Loj 2320.「清华集训 2017」生成树计数
  19. js中的call与apply随笔
  20. spring boot和swagger 整合

热门文章

  1. php 读取windows 的系统版本,硬盘,内存,网卡,数据流量等
  2. POJ 3626 BFS
  3. SQLite: sqlite_master(转)
  4. CentOS 源设置
  5. 应对加密js的三种方法
  6. 51nod 多重背包问题(二进制优化)
  7. 【VC++学习笔记三】控件自绘
  8. STM32CUBEF4 实现USB 虚拟串口
  9. python + eclipse + django + postgresql 开发网站(一)
  10. 【Henu ACM Round#18 B】Modulo Sum