当前位置: 首页> 文旅> 美景 > 牛客周赛50轮+cf955+abc363

牛客周赛50轮+cf955+abc363

时间:2025/7/9 8:30:46来源:https://blog.csdn.net/xxx_jsu/article/details/140526291 浏览次数:0次

D-小红的因式分解_牛客周赛 Round 50 (nowcoder.com)

思路:

巨蠢的题目,ax^2+bx+c=a1*a2*x^2+(b1*a2+b2*a1)x+b1*b2,即:

a=a1*a2,b=a1*b2+a2*b1,c=b1*b2

数据范围很小,直接暴力枚举吧(注意条件)

代码:

void solve()
{ll a, b, c, a1, a2, b1, b2;cin >> a >> b >> c;for (int a1 = -1000; a1 <= 1000; a1++){if (a1 == 0 || a % a1 != 0)continue;for (int b1 = -1000; b1 <= 1000; b1++){if (b1 == 0 || c % b1 != 0)continue;a2 = a / a1, b2 = c / b1;if (a1 * b2 + a2 * b1 == b){cout << a1 << " " << b1 << " " << a2 << " " << b2 << endl;return;}}}cout << "NO" << endl;return;
}

Problem - A - Codeforces

思路:

仔细看题目,题目的意思是有可能,即没可能的情况只有一种(即x1,y1和x2,y2相交的情况)

AC代码:

#define _CRT_SECURE_NO_WARNINGS 1
//------ 棘手大学 世界第一 ------//
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
//gcd最大公约数,lcm最小公倍数
typedef long long ll;
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr);
priority_queue<int, vector<int>, greater<int>> pq;
map<int, int>mp;
const int N = 2e6 + 10;
int mod(string a, ll b)//高精度a除以单精度b
{ll n = 0;for (int i = 0; i < a.size(); i++)  n = (n * 10 + (a[i] - '0')) % b;  //求出余数return n;
}
string gcd(string a, ll b)  // 欧几里得算法
{while (b != 0){ll temp = b;b = mod(a, b);a = to_string(temp);}return a;
}
inline int gcd1(int a, int b)//a、b不可以为0(很快)
{while (b ^= a ^= b ^= a %= b);return a;
}
inline int gcd2(int a, int b)//a、b可以为0(很快)
{if (b) while ((a %= b) && (b %= a));return a + b;
}
int lcm1(int a, int b) {return a * b / gcd1(a, b);
}
void solve()
{ll x1, y1, x2, y2;cin >> x1 >> y1;cin >> x2 >> y2;if (x1 < y1){if (x2 >= y2){cout << "NO" << endl;return;}else{cout << "YES" << endl;return;}}else if (x1 > y1){if (x2 <= y2){cout << "NO" << endl;return;}else{cout << "YES" << endl;return;}}else{cout << "YES" << endl;return;}
}
int main()
{IOS;int t;cin >> t;while(t--)solve();return 0;
}

Problem - B - Codeforces

思路:

不会,只能看题解写了(QWQ)

AC代码:

#include<bits/stdc++.h>using namespace std;void solve() {int x, y, k;cin >> x >> y >> k;while (k != 0 && x != 1) {int t = min(k, y - x % y);x += t;k -= t;while (x % y == 0) {x /= y;}}k %= (y - 1);x = x + k;cout << x << endl;
}int main() {int t;cin >> t;while (t--)solve();return 0;
}

abc363只a了三道题

A - Piling Up (atcoder.jp)

几个if语句就能过

void solve()
{ll n;cin >> n;if (n <= 1 && n <= 99){cout << 100 - n << endl;return;}if (n >= 100 && n <= 199){cout << 200 - n << endl;return;}if (n >= 200 && n <= 299){cout << 300 - n << endl;return;}if (n >= 300 && n <= 399){cout << 399 - n << endl;return;}
}

B - Japanese Cursed Doll (atcoder.jp)

思路:

判断当前有多少个>=p的就行,不满足要求的时候我们从最大的开始看(其实就是求有限范围里满足题目要求的最小值)

AC代码:

ll l[110];
bool cmp(ll a, ll b)
{return a > b;
}
void solve()
{ll n, t, p;cin >> n >> t >> p;ll k = 0;for (int i = 1; i <= n; i++){cin >> l[i];if (l[i] >= t)k++;}sort(l + 1, l + 1 + n, cmp);ll ans = 0, tt = k;if (k >= p){cout << "0" << endl;return;}for (int i = 1; i <= n; i++){if (tt == p){break;}if (l[i] < t){ans = max(ans, t - l[i]);tt++;}}cout << ans << endl;return;
}

关键字:牛客周赛50轮+cf955+abc363

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: