# [水题]hdoj 4432：Sum of divisors

把一个数的所有约数化为m进制之后，把这些数的每一位的平方相加求和，按照m进制输出。

纯模拟

```#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int len,num[1000];
void change(int n,int m)
{
len=0;
while(n!=0)
{
num[len++]=n%m;
n/=m;
}
}
int main()
{
int n,m,i,j,a,b,c,sum;
while(scanf("%d%d",&n,&m)!=EOF)
{
a=sqrt(n);
sum=0;
for(i=1;i<=a;i++)
{
if(n%i!=0)continue;
b=i;
while(b!=0)
{
c=b%m;
sum+=c*c;
b/=m;
}
b=n/i;
if(i==b)continue;
while(b!=0)
{
c=b%m;
sum+=c*c;
b/=m;
}
}
if(sum==0)
{
cout<<0<<endl;
continue;
}
change(sum,m);
for(i=len-1;i>=0;i--)
{
if(num[i]>9)printf("%c",num[i]-10+'A');
else printf("%d",num[i]);
}cout<<endl;
//cout<<sum<<endl;
}
return 0;
}```

[水题]hdoj 4432：Sum of divisors

• 0

开心

• 0

板砖

• 0

感动

• 0

有用

• 0

疑问

• 0

难过

• 0

无聊

• 0

震惊

KIDx 的解题报告 http://acm.hdu.edu.cn/listproblem.php?vol=31 4001：直接一个最长递增子序列模板
B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standa
Given an array of integers, find two numbers such that they add up to a specific target numbe
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding
1.题目： 三人行设计了一个灌水论坛。信息学院的学生都喜欢在上面交流灌水，传说在论坛上有一个“水