官方解答自然还没出,大二上的暴力杯我没赶上报名,大二下变成dp杯了但我才刚学算法,好了,大三下直接变成圈钱杯,好家伙我愣是一个dp都没看出来,好时代总是没赶上呜呜呜。
我愿称这次蓝桥杯为寄杯,或者说ICPC蓝桥站,(虽说我并没有参加过ICPC甚至连校队都没进
裁纸刀,裁…cai…? 菜!对!就是菜,冥冥之中第一题就告诉我我是条菜狗了
#include
#define ll long long
using namespace std;
int main()
{
cout << 4 + 21 + 22 * 19;
}
灭鼠灭鼠,灭得也许就是我叭
这题我认为的答案是LLVV,具咋做的我也忘了,反正就是思考每轮能不能让剩余的空位为偶数个,中间的空槽需要特别注意因为能连选2个,具体证法我也不知道…直觉,也许等结果出来我是错的。
这题的话,建议画个矩阵对应下,比如从a1加到a5的话,这样是不是就很清楚啦,对阵一下,减去平方和,再除以2
#include
#define ll long long
using namespace std;
ll a[300000];
ll pf[300000];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
ll s = 0;
ll pfh = 0;
for (int i = 0; i < n; i++)
{
cin >> a[i];
s += a[i];
pfh += (a[i] * a[i]);
}
ll re = s * s - pfh;
re =re/ 2;
cout << re;
return 0;
}
#include
#define ll long long
using namespace std;
ll a[300000];
vector<pair<ll, ll> >v;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
ll n, m, x;
cin >> n >> m >> x;
cin >> a[1];
for (int i = 2; i <= n; i++)
{
cin >> a[i];
for (int j = 1; j < i; j++)
if ((a[i] ^ a[j]) == x)
v.push_back(make_pair(j, i));
}
for (int i = 0; i < m; i++)
{
int l, r;
cin >> l >> r;
int j;
for (j = 0; j < v.size(); j++)
{
ll tx = v[j].first;
ll ty = v[j].second;
if ((tx>=l) && (ty<=r))
{
cout << "yes" << endl;
break;
}
}
if (j == v.size())
cout << "no" << endl;
}
return 0;
}
看到这题我直接兴奋好叭!什么?取模,同余式?看上去是求逆元的???巧了我前几天刚做过类似的题(指RSA),动笔算了算…还好我高中的等比数列如何求和还记得…等等,算着算着,n要趋于无穷,要取极限???寄了,不会,直接开摆,跳!
开始想着差分,但是差分也做不出来,还要考虑合并的事…也不会…直接寄了,但我还是要大胆的说,跳!
这题自己暴露的问题有点多,比如不会在坐标轴算角度什么的,虽说之前干过unity的活涉及了角度,但也都只是传参罢了,真要自己写角度自己还不会写
但瞎整整还是过了样例了,角度不同象限的比较我是分别处理了,坐标轴上为0.5,1.5,2.5,3.5象限hh,基本考虑就是按照角度大小弄个排序好的数组出来,然后一个个一遍遍循环
#include
#define ll long long
using namespace std;
int n;
ll l;
int vis[300000];
struct node
{
double xiangxian;
double theta;
double len;
int id;
double val;
int shunxu;
bool operator <(const node& a)const
{
if (xiangxian != a.xiangxian)
return xiangxian < a.xiangxian;
else
{
if (xiangxian == 1)
{
return theta < a.theta;
}
else if (xiangxian == 2)
{
return theta > a.theta;
}
else if (xiangxian == 3)
{
return theta < a.theta;
}
else if (xiangxian == 4)
{
return theta > a.theta;
}
else
return len < a.len;
}
}
};
vector<node>v;
struct newnode {
int id;
int shunxu;
bool operator <(const newnode& a)const
{
return id < a.id;
}
};
vector<newnode>nv;
int main()
{
cin >> n >> l;
for (int i = 0; i < n; i++)
{
double x, y, val;
cin >> x >> y >> val;
double the, length;
length = sqrt(x * x + y * y);
the = fabs((x) / (y));
double xiangxian;
if ((x > 0) && (y > 0))
xiangxian = 1;
else if ((x > 0) && (y < 0))
{
xiangxian = 2;
}
else if ((x < 0) && (y < 0))
{
xiangxian = 3;
}
else if ((x < 0) && (y > 0))
{
xiangxian = 4;
}
else
{
if (x == 0)
{
if (y > 0)
xiangxian = 0.5;
else
xiangxian = 2.5;
}
if (y == 0)
{
if (x > 0)
xiangxian = 1.5;
else
xiangxian = 3.5;
}
}
v.push_back(node{ xiangxian, the, length,i + 1,val,-1 });
}
sort(v.begin(), v.end());
//for (int i = 0; i < v.size(); i++)
//cout << v[i].id << ' ';
//cout << endl;
int flag = 1;
node pre = { -1000,-10000,-10000,-10000,-10000 };
int order = 1;
int cnt = 0;
while (flag)
{
flag = 0;
for (int i = 0; i < v.size(); i++)
{
if (vis[i])
continue;
if (v[i].len <= l)
{
//cout << i << endl;
vis[i] = 1;
l += v[i].val;
flag = 1;
v[i].shunxu = order;
order++;
if (pre.theta == v[i].theta)
{
//cout << "pre: " << pre.id << " " << pre.theta << endl;
//cout << "v[i]: " << v[i].id << " " << v[i].theta << endl;
v[i].shunxu = pre.shunxu;
}
else
{
// order += cnt;
// cnt = 0;
pre = v[i];
}
}
}
}
for (int i = 0; i < v.size(); i++)
{
newnode nd;
nd.id = v[i].id;
nd.shunxu = v[i].shunxu;
nv.push_back(nd);
}
sort(nv.begin(), nv.end());
cout << nv[0].shunxu;
for (int i = 1; i < nv.size(); i++)
cout << ' ' << nv[i].shunxu;
}
#include
#define ll long long
using namespace std;
ll mult_mod(ll a, ll b, ll m)
{
ll res = 0;
while (b) {
if (b & 1) res = (res + a) % m;
a = (a * 2) % m;
b >>= 1;
}
return res;
}
ll quick_mod(ll a, ll b, ll m)
{
ll ans = 1;
a = a % m;
while (b != 0)
{
if (b & 1) ans = mult_mod(ans, a, m) % m;
a = mult_mod(a, a, m) % m;
b >>= 1;
}
return ans;
}
int main()
{
int t;
cin >> t;
while (t--)
{
ll a;
cin >> a;
ll x=1, y=2;
int flag1 = 0, flag2 = 0;
for (ll i = 1; i * i <= a; i++)
{
if (a % i == 0)
{
ll t1 = i;
ll t2 = a / i;
flag1 = 0, flag2 = 0;
if (t1 != 1)
{
for (int j = 2; j * j <= t1; j++)
{
for (int e = 2; 1; e++)
{
ll tem = quick_mod(j, e, (int)1e+9);
if (tem == t1)
{
flag1 = 1;
break;
}
if (tem > t1)
break;
}
if (flag1)
break;
}
}
else
flag1 = 1;
//cout << "exe1\n";
//cout << t1 << " t1的值 " <
//cout << t1 << ' ' << t2 << endl;
if (t2 != 1)
{
for (int j = 2; j * j <= t2; j++)
{
//cout << j << endl;
for (int e = 2; 1; e++)
{
//cout <
ll tem = quick_mod(j, e, (int)1e+9);
//cout <<"tem: " << tem << endl;
if (tem == t2)
{
flag2 = 1;
break;
}
if (tem > t2)
break;
}
if (flag2)
break;
}
}
else flag2 = 1;
//cout << "exe2";
}
if (flag1 && flag2)
break;
}
//cout << "flag:" << flag1 << flag2;
if (flag1 && flag2)
cout << "yes" << endl;
else
cout << "no" << endl;
}
}
我靠,快速幂那应该是1e18次方的…尴尬,好难受,现在才发觉。
这题也不会…也还是暴力的,仿着去年的砝码称重的思路,用map写的
#include
#define ll long long
using namespace std;
map<pair<int, int>, ll >z;
map<pair<int,int> , ll >m;
const int maxn = 4e4 + 2;
bool flag[maxn][maxn];
int main()
{
int n, M, q;
cin >> n >> M >> q;
while (M--)
{
map<pair<int, int>, ll > m1 = m;
int l, r;
ll s;
cin >> l >> r >> s;
pair<int, int>p = make_pair(l, r);
m1[p] = s;
if (s == 0)
z[p] = 1;
map<pair<int, int>, ll >::iterator it = m.begin();
for (; it != m.end(); it++)
{
if (l == (*it).first.first)
{
int r1 = (*it).first.second;
if (r1 > r)
{
m1[make_pair(r + 1, r1)] = (*it).second - s;
if (((*it).second - s) == 0)
z[make_pair(r + 1, r1)] = 1;
//cout << "结果: " << r + 1 << ' ' << r1 << endl;
}
else if (r1 < r)
{
m1[make_pair(r1 + 1, r)] = s- (*it).second ;
if (((*it).second - s) == 0)
z[make_pair(r1 + 1, r)] = 1;
//cout << "结果: " << r1 + 1 << ' ' << r << endl;
}
}
else if(r == (*it).first.second)
{
int l1 = (*it).first.first;
if (l1 > l)
{
m1[make_pair(l, l1-1)] = s - (*it).second;
if (((*it).second - s) == 0)
z[make_pair(l, l1 - 1)] = 1;
//cout << "结果: " << l << ' ' << l1-1 << endl;
}
else if (l1 < l)
{
m1[make_pair(l1, l-1)] = (*it).second - s;
if (((*it).second - s) == 0)
z[make_pair(l1, l - 1)] = 1;
//cout << "结果: " << l1 << ' ' << l - 1 << endl;
}
}
}
m = m1;
}
while (q--)
{
int l, r;
cin >> l >> r;
if (m[make_pair(l, r)] == 0 && (z[make_pair(l, r)]!=1))
cout << "UNKNOWN" << endl;
else
cout << m[make_pair(l, r)] << endl;
}
}
好了,十分感谢您能看到这,想必这已经浪费了您生命中珍贵的几十分钟!因为这篇文章的有效信息堪称为0 …但这几十分钟我相信跟我们备战蓝桥杯所花的时间相比实在是九牛一毛
所以最后我还想说,蓝桥杯,rnm,退钱!