Đăng nhập để hỏi chi tiết


bool check(long long x)
{
for(long long i=2;i*i<=x;i++)
if(x%i==0)return false;
return x>1;
}
đây là hàm nt
Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
#include <bits/stdc++.h>
using namespace std;
bool check(long long x)
{
for(long long i=2;i*i<=x;i++)
if(x%i==0)return false;
return x>1;
}
int main() {
int n, d = 0;
cin >> n;
if (n == 1)
{
cout << 0;
return 0;
}
if (check(n))
{
cout << n - 1;
return 0;
}
for (int i = 1; i <= n; i++)
{
if (__gcd(i, n) == 1) d++;
}
cout << d;
return 0;
}Hãy giúp mọi người biết câu trả lời này thế nào?
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll euler_phi(ll n) {
ll result = n;
for (ll i = 2; i * i <= n; ++i) {
if (n % i == 0) {
while (n % i == 0)
n /= i;
result -= result / i;
}
}
if (n > 1)
result -= result / n;
return result;
}
int main() {
freopen("NTCN.INP", "r", stdin);
freopen("NTCN.OUT", "w", stdout);
ll n;
cin >> n;
cout << euler_phi(n) << endl;
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin
14
280
6
vote cho m 5 sao nhe