|
|
вернуться в форумWy WA on test , Please help me #include<iostream> #include<vector> #include<cmath> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif int n,m,y; long double x; long double time; vector< long double >vec;
cin >> n >> m >> y; if( n <= 0 || n >= 999) exit(1); if( m <= 1 || m >= 999) exit(1); if( y <= 0 || y >= 99) exit(1); for( x = 0; x < m; x++) { time = pow(x, n); if( (unsigned long)time % m == y) vec.push_back(x); } if( vec.size() == 0) cout << "-1";
else { for( unsigned int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } } return 0; } Re: Wy WA on test , Please help me Don't use pow~ Actually, the result of pow can exceed your data type(long). tips. (A*A) mod m = (A mod m) * (A mod m) Edited by author 01.10.2009 11:32 Re: Wy WA on test , Please help me (A * A) mod m = ((A mod m) * (A mod m)) mod m |
|
|