灰原哀 -
高清图片,堆糖,美图壁纸兴趣社区
牛客周赛 Round 29
A-小红大战小紫
模拟
1 2 3 4 5 6 7 8 9 10 11
| #include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if(a == b) cout << "draw\n"; else if(a > b) cout << "kou\n"; else cout << "yukari\n"; return 0; }
|
B-小红的白日梦
尽量换到白天即可
都等于没办法
一个等于就加2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #include <bits/stdc++.h> using namespace std; string s[2]; int main() { int n, sum = 0; cin >> n >> s[0] >> s[1]; for(int i = 0; i < n; i ++) { if(s[0][i] == 'Y' && s[1][i] == 'Y') sum += 3; else if(s[0][i] == 'Y' || s[1][i] == 'Y') sum += 2; } cout << sum << endl;
return 0; }
|
小红的小红红
分别找到"xiao""hong",然后进行删除即可
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #include <bits/stdc++.h> using namespace std; string s; int main() { cin >> s; int i = s.find("xiao"); s.erase(i, 4); i = s.find("hong"); s.erase(i, 4); cout << "xiaohong" << s << endl;
return 0; }
|
小红的中位数
暴力肯定不可以,应该是规律题
观察一下每次删除一个数字中位数的变化情况
来自题解
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| #include <bits/stdc++.h> using namespace std; const int N=1e6+10; struct Index{ int id; int num; }a[N]; int b[N];
bool cmp(Index a,Index b){ return a.num<b.num; }
void f(int x){ double w=1.0*x/2; printf("%.1f\n",w); } int main() { int n; cin >>n; for (int i=0;i<n;i++) { cin >>a[i].num; a[i].id=i; } sort(a,a+n,cmp); if (n%2==1) { for (int i=0;i<n/2;i++) b[a[i].id]=a[n/2].num+a[n/2+1].num; b[a[n/2].id]=a[n/2-1].num+a[n/2+1].num; for (int i=n/2+1;i<n;i++) b[a[i].id]=a[n/2-1].num+a[n/2].num; } else { for (int i=0;i<n/2;i++) b[a[i].id]=a[n/2].num*2; for (int i=n/2;i<n;i++) b[a[i].id]=a[n/2-1].num*2; } for (int i=0;i<n;i++)f(b[i]);
return 0; }
|
小红构造数组
质因数分解·,然后按奇数,偶数进行放置即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| #include <bits/stdc++.h> using namespace std;
typedef long long ll; const int N = 1e6 + 10;
ll len, outLine[N];
typedef struct Map{ ll key, value; }Map;
Map mp[N];
bool cmp(Map a, Map b){return a.value > b.value;}
int main() { ll x, ans = 0, cnt = 0; cin >> x; if(x == 1) return cout << "-1\n", 0; while(x % 2 == 0) { if(!cnt) cnt ++; ans ++, x /= 2, mp[cnt].key = 2, mp[cnt].value ++; } len += ans; for(ll i = 3; i * i <= x; i += 2) { ans = 0; if(x % i == 0) { ans = 0, cnt ++; mp[cnt].key = i; while (x % i == 0) x /= i, ans++, mp[cnt].value ++; } len += ans; } if(x > 1) { len ++, cnt ++; mp[cnt].key = x, mp[cnt].value = 1; } sort(mp + 1, mp + 1 + cnt, cmp); if(mp[1].value > (len + 1) / 2) cout << "-1\n"; else { cout << len << endl; int temp = 1; for(int i = 0; i < len; i += 2) { if(!mp[temp].value) temp ++; outLine[i] = mp[temp].key; mp[temp].value --; } for(int i = 1; i < len; i += 2) { if(!mp[temp].value) temp ++; outLine[i] = mp[temp].key; mp[temp].value --; } for(int i = 0; i < len; i ++) cout << outLine[i] << " \n"[i == len - 1]; }
return 0; }
|