|
|
back to boardint - AC, but long long - WA 2, Why? You can see two program with one difference - type. What wrong with first program? define _CRT_SECURE_NO_DEPRECATE #define _USE_MATH_DEFINES #include <utility> #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <cstdlib> #include <string> #include <cstring> #include <queue> using namespace std; long long n, m, y, x; bool yes = 0; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); scanf("%lld%lld%lld",&n,&m,&y); for (int i = 0; i < m; ++i) { x = i; if (n == 0) x = 1; for (int j = 2; j <= n; ++j) x = (x*i)%m; if (x%m == y) { yes = 1; printf("%lld", i); printf(" "); } } if (!yes) printf("-1"); return 0; } #define _CRT_SECURE_NO_DEPRECATE #define _USE_MATH_DEFINES #include <utility> #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <cstdlib> #include <string> #include <cstring> #include <queue> using namespace std; int n, m, y, x; bool yes = 0; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); scanf("%d%d%d",&n,&m,&y); for (int i = 0; i < m; ++i) { x = i; if (n == 0) x = 1; for (int j = 2; j <= n; ++j) x = (x*i)%m; if (x%m == y) { yes = 1; printf("%d", i); printf(" "); } } if (!yes) printf("-1"); return 0; } |
|
|