Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
Bài 1:
const fi='robot.inp';
fo='robot.out';
var f1,f2:text;
n,i,t:integer;
a:array[1..10000]of integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
t:=0;
for i:=1 to n do
begin
if a[i]=1 then t:=t+1
else t:=t-1;
end;
writeln(f2,t);
close(f1);
close(f2);
end.
Program hotrotinhoc;
const fi='cau2.inp';
fo='cau2.out';
var f: text;
s: ansistring;
i,n,d,max,min: integer;
a: array[1..1000] of string;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,s);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
s:=s+' ';
while length(s)<>0 do
begin
inc(d);
min:=1001;
max:=0;
a[d]:=copy(s,1,pos(' ',s)-1);
delete(s,1, pos(' ',s));
end;
for i:=1 to d do
begin
if length(a[i])>max then max:=length(a[i]);
if length(a[i])<min then min:=length(a[i]);
end;
write(f,min,' ',max);
close(f);
end;
begin
ip;
out;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i;
int main()
{
freopen("dayd.inp","r",stdin);
freopen("dayd.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]>0) cout<<a[i]<<" ";
return 0;
}
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1e7 + 1;
bool prime[MAXN];
void sieve(){
prime[0] = prime[1] = true;
for(int i = 2; 1LL * i * i < MAXN; ++i){
if(!prime[i]){
for(int j = i * i; j < MAXN; j += i){
prime[j] = true;
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int K;
cin >> K;
sieve();
while(K--){
int N;
cin >> N;
if(!prime[N]){
cout << "YES\n";
}
else{
cout << "NO\n";
}
}
return 0;
}