C++#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
int a;
cin>>a;
int res=a;
for(int i=2;i<=a/i;i++)
{
if(a%i==0)
{
res=res/i*(i-1);
while(a%i==0)a/=i;
}
}
if(a>1) res=res/a*(a-1);
cout<<res<<endl;
}
}
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool isName(const string& word) {
if (word.empty()) return false;
char first = word[0];
if (!(first >= 'A' && first <= 'Z')) return false;
int len = word.size();
for (int i = 1; i < len - 1; ++i) {
char c = word[i];
if (!(c >= 'a' && c <= 'z')) return false;
}
char last = word.back();
if ((last >= 'a' && last <= 'z') || last == '.' || last == '?' || last == '!') {
return true;
}
return false;
}
int main() {
freopen("word.in", "r", stdin);
freopen("word.out", "w", stdout);
int N;
cin >> N;
cin.ignore();
string line;
getline(cin, line);
vector<string> sentences;
string temp;
for (char c : line) {
if (c == ' ') {
if (!temp.empty()) {
sentences.push_back(temp);
temp.clear();
}
} else {
temp += c;
}
}
if (!temp.empty()) sentences.push_back(temp);
for (const string& sen : sentences) {
vector<string> words;
string w;
for (char c : sen) {
if (c == ' ') {
if (!w.empty()) {
words.push_back(w);
w.clear();
}
} else {
w += c;
}
}
if (!w.empty()) words.push_back(w);
int cnt = 0;
for (const string& word : words) {
if (isName(word)) cnt++;
}
cout << cnt << " ";
}
cout << endl;
return 0;
}