HDU 4432 Sum of divisors
来源:互联网 发布:淘宝拿别人的买家秀 编辑:程序博客网 时间:2024/05/16 18:04
比赛时做读完这个题,感觉一般的模拟过不了,就放过去了,结果发现就是个模拟题,按照题目意思做就可以了,另外要注意n要开方,否则会超时。
#include<cstdio>#include<cstring>#include<iostream>using namespace std;int n,m,digit[100];int ans;void comp(int a){ int aa=a; memset(digit,0,sizeof(digit)); int i=0; while(a) { digit[i]=a%m; ans+=digit[i]*digit[i]; a/=m; i++; } int u=n/aa; if(u!=aa) { a=u; i=0; memset(digit,0,sizeof(digit)); while(a) { digit[i]=a%m; ans+=digit[i]*digit[i]; a/=m; i++; } }}int main(){ //freopen("in.txt","r",stdin); int i; while(scanf("%d%d",&n,&m)!=EOF) { ans=0; for( i=1; i*i<=n; i++) { if(n%i==0) comp(i); } memset(digit,0,sizeof(digit)); i=0; while(ans) { digit[i++]=ans%m; ans/=m; } for(i--; i>=0; i--) { if(digit[i]>=10) printf("%c",digit[i]-10+'A'); else cout<<digit[i]; } cout<<endl; } return 0;}
- HDU 4432 Sum of divisors
- HDU:4432 Sum of divisors
- hdu 4432 Sum of divisors
- hdu 4432 Sum of divisors
- HDU 4432 Sum of divisors
- HDU 4432(Sum of divisors)
- hdu 4432 Sum of divisors(暴力)
- HDU 4432 Sum of divisors 质因数分解
- HDU-#4432 Sum of divisors(模拟)
- hdu 4432 Sum of divisors(模拟)
- HDU—— 4432 Sum of divisors
- HDU 4432 Sum of divisors (进制模拟)
- HDU 4432Sum of divisors (进制转换模板)
- hdu4432 Sum of divisors
- hdu4432 - Sum of divisors
- Sum of divisors
- Sum of divisors
- hdu4432 Sum of divisors
- android为模拟器安装应用
- android listiew适配器
- linux ubuntu下nginx的安装
- 开源项目Sliding Menu的下载、导入和运行
- NDK 编译 RTMPDump
- HDU 4432 Sum of divisors
- eclipse导入工程出现大红叹号
- jquery Datatable插件动态绑定数据库表
- ubuntu下nginx安装手记
- c语言中自增操作符与自减操作符
- JAVA CAS原理深度分析
- H264源码分析(三)
- 如何在dos下调用mfc的类?
- Turbo c 函数库中文说明