fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = (1 << 27);
  4. bool f[N + 1];
  5. vector<int> prime;
  6. void siv() {
  7. prime.push_back(2);
  8. for (int i = 3; i * i <= N; i += 2) {
  9. if (!f[i]) {
  10. for (int j = i * i; j <= N; j += i) {
  11. f[j] = 1;
  12. }
  13. }
  14. }
  15. for (int i = 3; i <= N; i += 2)
  16. if (!f[i])
  17. prime.push_back(i);
  18.  
  19. }
  20. char ans[][5] = { "Off", "On" };
  21. bool fact(long long x, long long y) {
  22. vector<long long> indx;
  23. for (int i = 0; prime[i] * prime[i] <= x && i < prime.size(); ++i) {
  24. while (x % prime[i] == 0) {
  25. x /= prime[i];
  26. indx.push_back(prime[i]);
  27. }
  28. }
  29. if (x > 1)
  30. indx.push_back(x);
  31. set<long long> ans;
  32. long long l = indx.size(), p;
  33. for (long long i = 0; i <= (1LL << l); ++i) {
  34. p = 1;
  35. for (long long j = 0; p <= y && j < l; ++j)
  36. if ((1 << j) & i)
  37. p *= indx[j];
  38. if (p <= y)
  39. ans.insert(p);
  40. }
  41. return ans.size() % 2;
  42. }
  43. int main(int argc, char **argv) {
  44. #ifndef ONLINE_JUDGE
  45. freopen("a.in", "r", stdin);
  46. #endif
  47. siv();
  48. long long a, b, c;
  49. while (scanf("%lld %lld %lld", &a, &b, &c) > 0) {
  50. b %= a;
  51. static int cas = 1;
  52. printf("Case %d: %s\n", cas++, ans[fact(c, b)]);
  53. }
  54. return 0;
  55. }
  56.  
Success #stdin #stdout 3.92s 134336KB
stdin
Standard input is empty
stdout
Standard output is empty