牛客小白月赛 68 题解
Posted transitivity-ptqwq
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了牛客小白月赛 68 题解相关的知识,希望对你有一定的参考价值。
网址:https://ac.nowcoder.com/acm/contest/51958
A - Tokitsukaze and New Operation
先将 \\(a,b\\) 的每一位分解,如果位数不一样直接 \\(-1\\)。
设 \\(a,b\\) 有 \\(n\\) 位,\\(a\\) 的第 \\(i\\) 为 \\(x_i\\) & \\(b\\) 的地 \\(i\\) 为 \\(y_i\\)。
那么就不带空格的输出 \\(x_1y_1\\) & \\(x_2y_2\\) & \\(\\dots\\) & \\(x_ny_n\\)。
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
typedef long long ll;
typedef pair < int, int > PII;
typedef int itn;
mt19937 RND_MAKER (chrono :: steady_clock :: now ().time_since_epoch ().count ());
inline ll randomly (const ll l, const ll r) return (RND_MAKER () ^ (1ull << 63)) % (r - l + 1) + l;
//#define int long long
const double pi = acos (-1);
//__gnu_pbds :: tree < Key, Mapped, Cmp_Fn = std :: less < Key >, Tag = rb_tree_tag, Node_Upadte = null_tree_node_update, Allocator = std :: allocator < char > > ;
//__gnu_pbds :: tree < PPS, __gnu_pbds :: null_type, less < PPS >, __gnu_pbds :: rb_tree_tag, __gnu_pbds :: tree_order_statistics_node_update > tr;
signed main ()
int _;
scanf ("%d", &_);
while (_ --)
int a, b;
scanf ("%d %d", &a, &b);
string S = "", T = "";
while (a)
S += (char) (a % 10 + \'0\');
a /= 10;
reverse (S.begin (), S.end ());
while (b)
T += (char) (b % 10 + \'0\');
b /= 10;
reverse (T.begin (), T.end ());
if (S.size () != T.size ()) printf ("-1\\n");
else
for (int i = 0;i < T.size (); ++ i)
int a = S[i] - \'0\', b = T[i] - \'0\';
printf ("%d", a * b);
printf ("\\n");
return 0;
B - Tokitsukaze and Order Food Delivery
如果在第 \\(i\\) 家吃饭,就枚举点哪一道菜,剩下的计算价格就是模拟了,注意答案一定是非负的。
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
typedef long long ll;
typedef pair < int, int > PII;
typedef int itn;
mt19937 RND_MAKER (chrono :: steady_clock :: now ().time_since_epoch ().count ());
inline ll randomly (const ll l, const ll r) return (RND_MAKER () ^ (1ull << 63)) % (r - l + 1) + l;
#define int long long
const double pi = acos (-1);
//__gnu_pbds :: tree < Key, Mapped, Cmp_Fn = std :: less < Key >, Tag = rb_tree_tag, Node_Upadte = null_tree_node_update, Allocator = std :: allocator < char > > ;
//__gnu_pbds :: tree < PPS, __gnu_pbds :: null_type, less < PPS >, __gnu_pbds :: rb_tree_tag, __gnu_pbds :: tree_order_statistics_node_update > tr;
int _, n, a, b, k[100005], x[100005], y[100005], v[100005];
signed main ()
scanf ("%lld", &_);
while (_ --)
scanf ("%lld %lld %lld", &n, &a, &b);
int res = 1e18;
for (int i = 1;i <= n; ++ i)
scanf ("%lld %lld %lld", &k[i], &x[i], &y[i]);
for (int j = 1;j <= k[i]; ++ j) scanf ("%lld", &v[j]);
int ans = 1e18;
for (int j = 1;j <= k[i]; ++ j)
int qwq = v[j];
if (qwq >= a && qwq >= x[i]) qwq -= b, qwq -= y[i], qwq = qwq < 0 ? 0 : qwq;
else if (qwq >= a && qwq < x[i]) qwq -= b, qwq = qwq < 0 ? 0 : qwq;
else if (qwq < a && qwq >= x[i]) qwq -= y[i], qwq = qwq < 0 ? 0 : qwq;
ans = min (ans, qwq);
res = min (res, ans);
printf ("%lld\\n", res);
return 0;
以上是关于牛客小白月赛 68 题解的主要内容,如果未能解决你的问题,请参考以下文章