int kase = 0,S; boolcheck(int n,int m) { int q = sqrt(n+0.5); int ret = 0; for (int i = 1; i <= q; i++) if (n % i == 0) ret += i+n/i; if (q*q == n) ret -= q; return (ret == m); } intmain(int argc, char *argv[]) { while(scanf("%d",&S) == 1 && S) { bool flag = 0; if (S == 1) { printf("Case %d: 1\n",++kase); continue; } for (int i = S-1; i >= 1; i--) if (check(i,S)) { flag = 1; printf("Case %d: %d\n",++kase,i); break; } if(!flag) printf("Case %d: %d\n",++kase,-1); } return0; }
intmain(int argc, char *argv[]) { getLL(T); while(T--) { getLL(x);getLL(k); a = floor(double(x)/double(k)); b = ceil(double(x)/double(k)); d = a == b ? a : 1; if (a == b) X = 0,Y = k; else { ex_gcd(a,b,X,Y,d); X *= x, Y *= x; } printf("%lld %lld\n",X,Y); } return0; }
//UVA-10692 #include<bits/stdc++.h> constint maxn = 15; int A[maxn], k; intpow_mod(int a, int n, int M) { int ans = 1; while (n) { if (n&1) ans = ans * a % M; a = a * a % M; n /= 2; } return ans; }
inteuler_phi(int n) { int m = (int)sqrt(n+0.5); int ans = n; for (int i = 2; i <= m; i++) { if (n % i == 0) { ans = ans / i * (i-1); while (n%i==0) n /= i; } }
if (n > 1) ans = ans / n * (n - 1); return ans; }
intsolve(int d, int M) { if (d == k - 1) return A[d]%M; int phi = euler_phi(M); int c = solve (d+1, phi) + phi; return pow_mod(A[d], c, M); }
intmain(int argc, char *argv[]) { int cas = 1; char str[maxn];
while (scanf("%s", str) == 1 && strcmp(str, "#")) { int M; sscanf(str, "%d", &M); scanf("%d", &k); for (int i = 0; i < k; i++) scanf("%d", &A[i]); printf("Case #%d: %d\n", cas++, solve(0, M)); } return0; }