Test instructions: Given the n,m, all the factors of n are transferred to M-system, and then the squares of each sum are summed.
Analysis: According to its requirements to do just fine, notice is, is the factor, cannot have duplicates ... For example, 4 of the factor is only one 2, there is the output 10 in the above, to use AB.
But I'm using AB. Didn't read the good question .... It deserved WA several times.
The code is as follows:
#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include <cstdio> #include <string> #include < cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include < queue> #include <algorithm> #include <vector> #include <map> #include <cctype> #include < Stack>using namespace std; typedef long Long Ll;typedef pair<int, int> p;const int INF = 0x3f3f3f3f;const double inf = 0x3f3f3f3f3f3f;const Double PI = ACOs ( -1.0); const double EPS = 1e-8;const int maxn = ten + 5;const int mod = 1e9 + 7; const char *mark = "+-*"; const int dr[] = {-1, 0, 1, 0};const int dc[] = {0, 1, 0, -1};int N, m;inline bool is_in (int R, I NT c) {return R >= 0 && r < n && C >= 0 && C < m;} int a[70];int Solve (int x) {int ans = 0; while (x) {ans + = (x% m) * (x% m); x/= m; } return ans; int main () {while (scanf ("%d%d", &n, &m) = = 2) {int t = SQRT (n+0.5); int ans = 0; for (int i = 1; I <= t; ++i) {if (n% i = = 0) {ans + = solve (i); if (n/i! = i) ans + = solve (n/i); }} int cnt = 0; while (ans) {a[cnt++] = ans% m; Ans/= m; } for (int i = cnt-1; I >= 0; i.) if (A[i] <) printf ("%d", a[i]); else printf ("%c", ' A ' +a[i]-10); printf ("\ n"); } return 0;}
HDU 4432 Sum of divisors (water problem, binary conversion)