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.
#include <bits/stdc++.h>;
using namespace std;
int main()
{
long i,n;
float tbc,dem,t,a[10000];
cin>>n;
for (i=1; i<=n; i++)
{
cin>>a[i];
}
dem=0;
t=0;
for (i=1; i<=n; i++)
if (a[i]<0)
{
dem=dem+1;
t=t+a[i];
}
tbc=t/dem;
cout<<fixed<< setprecision(2)<<tbc;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
write(a[i]:4);
writeln;
for i:=1 to n do
if (a[i]+a[i+1] mod 10=0) then
begin
writeln(a[i],' ',a[i+1]);
writeln(i,' ',i+1);
end;
readln;
end.
#include <iostream>
#include <map>
using namespace std;
int main() {
int n;
cin >> n;
map<int, int> count;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
count[x]++;
}
int ans = 0;
for (auto p : count) {
int x = p.second;
ans += (x * (x - 1)) / 2;
}
cout << ans;
return 0;
}
#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;
}
const fi='divk.inp';
fo='divk.out';
var f1,f2:text;
a:array[1..100]of integer;
i,n,k,dem,j,x,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n,k);
for i:=1 to n do
read(f1,a[i]);
dem:=0;
for i:=1 to n do
for j:=1 to n do
begin
if i<j then
begin
t:=0;
for x:=i to j do
t:=t+a[x];
if t=k then inc(dem);
end;
for i:=1 to n do
if k=a[i] then inc(dem);
writeln(f2,dem);
close(f1);
close(f2);
end.
#include <bits/stdc++.h>
using namespace std;
#define nhungcute ios_base::sync_with_stdio; cin.tie(0); cout.tie(0);
const int N=1500;
long long n,k,a[N],i,j,c[N][101];
int main(){
nhungcute
cin>>n>>k;
for(i=1;i<=n;i++)
cin>>a[i];
for(i=1;i<=n;i++){
a[i]=a[i]%k;
}
for(i=1;i<k;i++)
c[1][i] =-1e9;
c[1][a[0]]=0;
c[1][a[1]]=1;
for(i=2;i<=n;i++){
for(j=0;j<k;j++){
c[i][j]=max(c[i-1][j],c[i-1][(j-a[i]+k)%k]+1);
}
}
cout<<c[n][0];
return 0;
}
uses crt;
var n,i,chan,tonchan:integer;
a:array[1..100] of integer;
begin
write('nhap n '); readln(n);
for i:=1 to n do
begin
write('a[i]='); readln(a[i]);
end;
writeln("in cac phan tu trong mang");
for i:=1 to n do
begin
writeln(a[i]);
end;
writeln("in cac phan tu chan");
chan:=0;
for i:=1 to n do
if n mod 2=0 then begin writeln(a[i]); chan:=chan+1; end;
write('tong cac phan tu chan ',chan);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,t,dem,j;
int main()
{
cin>>n;
x=n;
t=0;
while (n>0)
{
t=t+n%10;
n=n/10;
}
cout<<t;
dem=0;
for (i=2; i<=x; i++)
{
bool kt=true;
for (j=2; j*j<=i; j++)
if (i%j==0) kt=false;
if (kt==true) dem++;
}
cout<<dem;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
const long long maxn=1e9+10;
long long a[maxn],c[maxn]={0},n;
int main()
{
cin>>n;
for (int i=1; i<=n; i++)
{
cin>>a[i];
c[a[i]]+=1;
}
sort(a+1,a+n+1);
for (int i=0; i<=a[n]; i++)
if (C[i]>0) cout<<i," xuat hien ",C[i]," lan";
}
#include <bits/stdc++.h>
using namespace std;
const long long maxn=1e9+10;
long long a[maxn],c[maxn]={0},n;
int main()
{
cin>>n;
for (int i=1; i<=n; i++)
{
cin>>a[i];
c[a[i]]+=1;
}
sort(a+1,a+n+1);
for (int i=0; i<=a[n]; i++)
if (C[i]>0) cout<<i," xuat hien ",C[i]," lan";
}