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;
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;
}
N = int(input())
A = 0
B = 0
So_uoc = 0
KQ = ""
for x in range(1, N):
if (x%2==0) and (x%3==0):
A += 1
if (x>0) and (N%x==0):
if (x>B):
B = x
for i in range(1, N+1):
if (N%i==0):
So_uoc += 1
if (So_uoc == 2):
KQ = "YES"
else:
KQ = "NO"
print(A)
print(B)
print(len(str(N)))
print(KQ)
(Chẳng biết đúng không đâu )
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio (0);
cin.tie (0);
cout.tie(0);
long long i,du,nho,k;
string s1,s2,res;
cin>>s1>>s2;
while(s1.size()<s2.size())
s1='0'+s1;
while(s2.size()<s1.size())
s2='0'+s2;
i=s1.size()-1;
nho=0;
res="";
while(i>=0){
k=s1[i]-48+s2[i]-48+nho;
nho=k/10;
du=k%10;
res=(char)(du+48)+res;
i--;
}
if(nho==1)
res='1'+res;
cout<<res;
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;
}
#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 <iostream>
using namespace std;
int main()
{
int i,n,a,b,kt,j;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
for (i=a; i<=b; i++)
{
if (i>2)
{
kt=0;
for (j=2; j<=i-1; j++)
if (i%j==0) kt=1;
if (kt==0) cout<<i<<" ";
}
}
return 0;
}
duma đề thi thử tỉnh tao
const fi='snt.inp';
fo='snt.out';
var f1,f2:text;
n,i:integer;
a,b:array[1..100]of integer;
{-----------------ham-kiem-tra-so-nguyen-to-------------------------}
function ktra(x:integer):boolean;
var kt:boolean;
i:integer;
begin
kt:=true;
for i:=2 to x-1 do
if x mod i=0 then kt:=false;
if kt=true then ktra:=true
else ktra:=false;
end;
{---------------------chuong-trinh-chinh---------------------}
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
readln(f1,a[i],b[i]);
for i:=1 to n do
if ktra(a[i]-b[i])=true then writeln(f2,'YES')
else writeln(f2,'NO');
close(f1);
close(f2);
end.