fork download
  1. #include<bits/stdc++.h>
  2. //#pragma GCC optimize ("Ofast, no-stack-protector, unroll-loops, fast-math, O3")
  3. using namespace std;
  4. const char el ='\n';
  5. const char sp = ' ';
  6. typedef long long ll;
  7. #define ios {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
  8. #define mp(x, y) make_pair(x, y)
  9. #define popCnt(x) (__builtin_popcountll(x))
  10. #define pb(x) push_back(x);
  11. #define F first
  12. #define S second
  13. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  14. int rand(int l , int r)
  15. {
  16. return uniform_int_distribution<int>(l , r)(rng) ;
  17. }
  18. vector<int> lp,primes;
  19. static void sieveLinear(int N) {
  20. lp = vector<int>(N+1);// lp[i] = least prime divisor of i
  21. primes = vector<int>();
  22. for (int i = 2; i <= N; ++i) {
  23. if (lp[i] == 0) {
  24. primes.push_back(i);
  25. lp[i] = i;
  26. }
  27. int curLP = lp[i];
  28. for (int p : primes)// all primes smaller than or equal my lowest prime divisor
  29. if (p > curLP || p * 1ll * i > N)
  30. break;
  31. else
  32. lp[p * i] = p;
  33. }
  34. }
  35. int main() {
  36. ios;
  37. // freopen("input.txt", "r", stdin);
  38. // freopen("output.txt", "w", stdout);
  39. int n;
  40. vector<int> arr(n);
  41. cin >> n;
  42. for(int i = 0; i < n; i++){
  43. cin >> arr[i];
  44. }
  45. sieveLinear(1e6);
  46. vector<vector<int>> factorization(n);
  47. vector<int> cnt(1e6 + 1);
  48. for(int x : arr){
  49. cnt[x]++;
  50. }
  51. for(int i = 2; i <= 1e6; i++){
  52. for(int j = 2 * i ; j <= 1e6; j+= i){
  53. cnt[i] += cnt[j];
  54. }
  55. }
  56. for(int i = 0; i < n; i++){
  57. int cur = arr[i];
  58. while(cur > 1){
  59. int curLp = lp[cur];
  60. while(cur % curLp == 0)
  61. cur /= curLp;
  62. factorization[i].push_back(curLp);
  63. }
  64. int all = n;
  65. for(int j = 1 ; j < 1 << factorization[i].size(); j++){
  66. int mul = 1;
  67. for(int k = 0 ; k < factorization[i].size(); k++){
  68. if((1<<k) & j){
  69. mul *= factorization[i][k];
  70. }
  71. }
  72. if(popCnt(j) % 2){
  73. all -= cnt[mul];
  74. }
  75. else all += cnt[mul];
  76. }
  77. if(all > 0){
  78. // answer found;
  79. for(int j = 0; j < n; j++){
  80. if(__gcd(arr[i],arr[j]) == 1){
  81. cout<< i + 1 << sp << j + 1 << el;
  82. return 0;
  83. }
  84. }
  85. }
  86. }
  87.  
  88. return 0;
  89. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include<bits/stdc++.h>
        ^
Main.java:4: error: class, interface, or enum expected
const char el ='\n';
^
Main.java:5: error: class, interface, or enum expected
const char sp = ' ';
^
Main.java:6: error: class, interface, or enum expected
typedef long long ll;
^
Main.java:7: error: illegal character: '#'
#define ios {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
^
Main.java:7: error: class, interface, or enum expected
#define ios {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
        ^
Main.java:7: error: class, interface, or enum expected
#define ios {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
                                           ^
Main.java:7: error: class, interface, or enum expected
#define ios {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
                                                       ^
Main.java:7: error: class, interface, or enum expected
#define ios {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
                                                                   ^
Main.java:8: error: illegal character: '#'
#define mp(x, y) make_pair(x, y)
^
Main.java:9: error: illegal character: '#'
#define popCnt(x) (__builtin_popcountll(x))
^
Main.java:10: error: illegal character: '#'
#define pb(x) push_back(x);
^
Main.java:11: error: illegal character: '#'
#define F first
^
Main.java:11: error: class, interface, or enum expected
#define F first
        ^
Main.java:12: error: illegal character: '#'
#define S second
^
Main.java:14: error: class, interface, or enum expected
int rand(int l , int r)
^
Main.java:17: error: class, interface, or enum expected
}
^
Main.java:19: error: class, interface, or enum expected
static void sieveLinear(int N) {
       ^
Main.java:21: error: class, interface, or enum expected
    primes = vector<int>();
    ^
Main.java:22: error: class, interface, or enum expected
    for (int i = 2; i <= N; ++i) {
    ^
Main.java:22: error: class, interface, or enum expected
    for (int i = 2; i <= N; ++i) {
                    ^
Main.java:22: error: class, interface, or enum expected
    for (int i = 2; i <= N; ++i) {
                            ^
Main.java:25: error: class, interface, or enum expected
            lp[i] = i;
            ^
Main.java:26: error: class, interface, or enum expected
        }
        ^
Main.java:28: error: class, interface, or enum expected
        for (int p : primes)// all primes smaller than or equal my lowest prime divisor
        ^
Main.java:31: error: class, interface, or enum expected
            else
            ^
Main.java:33: error: class, interface, or enum expected
    }
    ^
Main.java:39: error: class, interface, or enum expected
    int n;
    ^
Main.java:40: error: class, interface, or enum expected
    vector<int> arr(n);
    ^
Main.java:41: error: class, interface, or enum expected
    cin >> n;
    ^
Main.java:42: error: class, interface, or enum expected
    for(int i = 0; i < n; i++){
    ^
Main.java:42: error: class, interface, or enum expected
    for(int i = 0; i < n; i++){
                   ^
Main.java:42: error: class, interface, or enum expected
    for(int i = 0; i < n; i++){
                          ^
Main.java:44: error: class, interface, or enum expected
    }
    ^
Main.java:46: error: class, interface, or enum expected
    vector<vector<int>> factorization(n);
    ^
Main.java:47: error: class, interface, or enum expected
    vector<int> cnt(1e6 + 1);
    ^
Main.java:48: error: class, interface, or enum expected
    for(int x : arr){
    ^
Main.java:50: error: class, interface, or enum expected
    }
    ^
Main.java:51: error: class, interface, or enum expected
    for(int i = 2; i <= 1e6; i++){
                   ^
Main.java:51: error: class, interface, or enum expected
    for(int i = 2; i <= 1e6; i++){
                             ^
Main.java:52: error: class, interface, or enum expected
        for(int j = 2 * i ; j <= 1e6; j+= i){
                            ^
Main.java:52: error: class, interface, or enum expected
        for(int j = 2 * i ; j <= 1e6; j+= i){
                                      ^
Main.java:54: error: class, interface, or enum expected
        }
        ^
Main.java:56: error: class, interface, or enum expected
    for(int i = 0; i < n; i++){
                   ^
Main.java:56: error: class, interface, or enum expected
    for(int i = 0; i < n; i++){
                          ^
Main.java:58: error: class, interface, or enum expected
        while(cur > 1){
        ^
Main.java:60: error: class, interface, or enum expected
            while(cur % curLp == 0)
            ^
Main.java:62: error: class, interface, or enum expected
            factorization[i].push_back(curLp);
            ^
Main.java:63: error: class, interface, or enum expected
        }
        ^
Main.java:65: error: class, interface, or enum expected
        for(int j = 1 ; j < 1 << factorization[i].size(); j++){
        ^
Main.java:65: error: class, interface, or enum expected
        for(int j = 1 ; j < 1 << factorization[i].size(); j++){
                        ^
Main.java:65: error: class, interface, or enum expected
        for(int j = 1 ; j < 1 << factorization[i].size(); j++){
                                                          ^
Main.java:67: error: class, interface, or enum expected
            for(int k = 0 ; k < factorization[i].size(); k++){
            ^
Main.java:67: error: class, interface, or enum expected
            for(int k = 0 ; k < factorization[i].size(); k++){
                            ^
Main.java:67: error: class, interface, or enum expected
            for(int k = 0 ; k < factorization[i].size(); k++){
                                                         ^
Main.java:70: error: class, interface, or enum expected
                }
                ^
Main.java:74: error: class, interface, or enum expected
            }
            ^
Main.java:76: error: class, interface, or enum expected
        }
        ^
Main.java:79: error: class, interface, or enum expected
            for(int j = 0; j < n; j++){
                           ^
Main.java:79: error: class, interface, or enum expected
            for(int j = 0; j < n; j++){
                                  ^
Main.java:82: error: class, interface, or enum expected
                    return 0;
                    ^
Main.java:83: error: class, interface, or enum expected
                }
                ^
Main.java:89: error: class, interface, or enum expected
}
^
64 errors
stdout
Standard output is empty