Những câu hỏi liên quan
APOK FF
Xem chi tiết
minh dương
Xem chi tiết
Long ca ca
Xem chi tiết
Gia Huy
29 tháng 6 2023 lúc 6:45

```python

def nen_day_so(N):
if N == 1:
return 1
else:
return (nen_day_so(N-1) + N) % 1000000000

N = int(input("Nhập N: "))
ket_qua = nen_day_so(N)
print(ket_qua)
```

Thu Hiền
Xem chi tiết
Nguyễn Dư Thành Đạt
Xem chi tiết
Anh Thư
Xem chi tiết
Minh Lệ
10 tháng 4 2021 lúc 18:25

Program HOC24;

var d,i,n: integer;

a: array[1..1000] of integer;

t: longint;

function nt(x: longint): boolean;

var j: longint;

begin

nt:=true;

if (x=2) or (x=3) then exit;

nt:=false;

if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(x)) do

begin

if (x mod j=0) or (x mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

begin

write('Nhap N: '); readln(n);

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

d:=0; t:=0;

for i:=1 to n do

if nt(a[i]) then

begin

d:=d+1;

t:=t+a[i];

end;

writeln('Co ',d,' so nguyen to trong day');

write('Tong cac so nguyen to trong day la: ',t);

readln

end.

Nguyễn Lê Phước Thịnh
10 tháng 4 2021 lúc 20:18

uses crt;

var a:array[1..1000]of integer;

i,n,dem,t,j,kt:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

dem:=0;

t:=0;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to a[i]-1 do 

 if a[i] mod j=0 then kt:=1;

if kt=0 then

begin

inc(dem);

t:=t+a[i];

end;

end;

writeln('So luong so nguyen to la: ',dem);

writeln('Tong cac so nguyen to la: ',t);

readln;

end.

Phan Văn Thái Dương
Xem chi tiết
TRIẾT PHẠM
Xem chi tiết
89654DAUUBUOIIIII956
Xem chi tiết
Phía sau một cô gái
26 tháng 7 2023 lúc 19:45

#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;

}