codeforces 918 div4
#include<cmath> #include<iostream> #define ll long long using namespace std; bool issq(ll n){ ll root = sqrt(n); return root*root == n ;
// 标准写法,其他写法有精度问题 } int main(){ int t; cin>>t; while (t--){ ll x; cin>>x; ll sum =0; while (x--){ ll y; cin>>y; sum+=y; } if (issq(sum)) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }
D
英语中有两种音节: CV (辅音后元音)或 CVC (元音前后辅音)。例如, ba 、 ced 、 bab 是音节,但 aa 、 eda 、 baba 不是音节。
例如 : 给定单词bacedbab
它会被分成几个音节:ba. cedb .bab
(点,表示一个音节边界)。
: 把这个单词拆成音节。
例如,给定单词 bacedbab
它会被分成几个音节:ba. cedb .bab
(点,表示一个音节边界)。
#include "bits/stdc++.h" using namespace std; void solve() { int n; string s; cin >> n >> s; string t; // 倒着来 for (int i = n - 1; i >= 0; ) { if (s[i] == 'a' || s[i] == 'e') { for (int j = 0; j < 2; j++, i--) { t += s[i]; // vc 往后两个数包括自身 } } else { for (int j = 0; j < 3; j++, i--) { t += s[i]; // cvc 往后三个数包括自身 } } if (i > 0) { t += "."; } } reverse(t.begin(), t.end()); //反转字符串 cout << t << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t; cin >> t; while (t--) { solve(); } return 0; }

浙公网安备 33010602011771号