boolis_prime(int x){ if (x == 1) returntrue; for (int i = 2; i * i <= x; i++) { if (x % i == 0) returnfalse; } returntrue; } int a[N]; voidsolve(){ int T; cin >> T; while (T--) { int n; cin >> n; int ans = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; ans += a[i]; } if (!is_prime(ans)) { cout << n << endl; for (int i = 1; i <= n; i++) cout << i << ' '; cout << endl; } else { cout << n - 1 << endl; int f = 0; for (int i = 1; i <= n; i++) { if (!is_prime(ans-a[i])) { f = i; break; } } for (int i = 1; i <= n; i++) { if (i != f) cout << i << ' '; } cout << endl; } } }
voidsolve(){ int T; cin >> T; while (T--) { int n, m; cin >> n >> m; vector<int> vis(n+1); for (int i = 1; i <= m; i++) { int a, b, c; cin >> a >> b >> c; vis[b] = 1; } int t = 0; for (int i = 1; i <= n; i++) if (!vis[i]) t = i; for (int i = 1; i <= n; i++) { if (i != t) cout << i << ' ' << t << endl; } } }
string s[N]; int f[N]; voidsolve(){ int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 1; i < n; i++) { for (int j = 1; j < m; j++) { if (s[i][j-1] == 'X' && s[i-1][j] == 'X') { f[j] = 1; } } } for (int i = 1; i < m; i++) f[i] += f[i-1]; int q; cin >> q; while (q--) { int l, r; cin >> l >> r; l--, r--; if (f[r] == f[l]) cout << "YES" << endl; else cout << "NO" << endl; } }