A.嘤嘤不想做计几喵
题意:计算(a-b)-b*10
思路:水题,简单模拟下就行
ac代码:
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
void Miraitowa(){
ll a, b;
cin >> a >> b;
ll res = (a - b) - b * 10;
cout << res << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
// int t;
// cin>>t;
// while(t--)
Miraitowa();
return 0;
};
B.嘤嘤不想打怪兽喵
题意:有种魔法能将x分裂成两个x/2向下取整,问用多少次魔法能将x变为0
思路:通过模拟几个数可以发现他的过程最后像一颗完全满二叉树,魔法次数会分裂两个,所以两层有1个,三层有1+2个,四层有1+2+4个,则魔法次数为层数减一的等差数列和
ac代码:
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const int mod = 1e9 + 7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
void Miraitowa()
{
ll h;
cin >> h;
ll res = 0;
while(h) h /= 2, res++;
ll sum = 0;
for (int i = 0; i < res;i++)
sum += (1ll << i);
cout << sum << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
// int t;
// cin>>t;
// while(t--)
Miraitowa();
return 0;
};
C.嘤嘤不想买东西喵
题意:有排成一排的n件商品,你可以任选一段子段和将价格变为x购买,问最多能省多少钱
思路:首先有n件商品,一开始每个商品都有自己的价钱a[i]
,当我选的一段子段和包含当前商品时就会变成x,省下的钱可以表示为a[i]-x
,那么我们先将每件商品的价格减去x,则整个数组中元素表示为我选这个商品能省下多少钱,我要选一段使得我能省下的钱最多,是一道经典的最大子段和问题
ac代码:
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
const int N = 3e5 + 10;
ll a[N];
void Miraitowa(){
int n, x;
cin >> n >> x;
for (int i = 1; i <= n;i++)
cin >> a[i];
for (int i = 1; i <= n;i++)
a[i] -= x;
ll num = 0, pre = 0;
for (int i = 1; i <= n;i++){
num = max(num + a[i], a[i]);
pre = max(pre, num);
}
cout << pre << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
// int t;
// cin>>t;
// while(t--)
Miraitowa();
return 0;
};
D.嘤嘤不想求异或喵
题意:嘤嘤有两个整数l,r,他想知道l r所有整数的异或和是多少
分析:求异或和我们可以看每一位,每位之间互不影响,然后我们发现数字之间四个一组为一个循环节异或和为0
4k,4k+1,4k+2,4k+3
最后两位异或为0,同时前面位数都相同异或为0,整体为0,那么我们先求1到 l 和1到
r 之间的异或和,l r之间的异或和通过再次异或1到 l-1之间的异或和得到
此时有四种情况,以r为例:
r%4==0 ,它为新循环节的开始,他与前面的0异或还是他本身,返回r
r%4==1 这个循环节有两个,前面的两两相等异或相同,后两位异或为1,则返回1
r%4==2 这个循环节有三个,前面的三个数都相同,但是两个异或已经是零了,那么前面为r前面的数,后两位为11,则返回r+1
r%4==3 这个循环节有四个为一组,返回0
ac代码:
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const int mod = 1e9 + 7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
ll cal(ll r)
{
if (r % 4 == 1)
return 1;
else if (r % 4 == 2)
return r + 1;
else if (r % 4 == 3)
return 0;
return r;
}
void Miraitowa()
{
ll l, r;
cin >> l >> r;
if (l == r)
cout << l << endl;
else
{
ll a = cal(r), b = cal(l - 1);
cout << (a ^ b) << endl;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--)
Miraitowa();
return 0;
};
E.嘤嘤不想解方程
题意:求解y=a1x^2+b1x+c1和a2x+b2y+c2=0
的联立方程的解的数量
思路:将y带入到第二个式子里,发现这式子变成了一个二次函数,二次函数的根的求解令y等于0
ac代码:
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const int mod = 1e9 + 7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
void Miraitowa()
{
//ax^2+bx+c=0
ll a1, b1, c1, a2, b2, c2;
cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
lll a = a1 * b2, b = a2 + b1 * b2, c = c2 + c1 * b2;
if (a == 0)
{
if (b == 0)
{
if (c == 0)
cout << "INF" << endl; //当a,b,c都为0的时候,x有无数个解使得0==0
else
cout << 0 << endl; // 当a,b等于0,c不等于0的时候,x没有一个解使得c==0
}
else
cout << 1 << endl; //当a==0,b!=0时,则变为一次函数,有一个解
}
else // a不等于0,用求根公式求解
{
lll del = b * b - 4 * a * c;
ll temp = 1;
if (del > 0) temp = 2;
else if (del < 0) temp = 0;
cout << temp << endl;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--)
Miraitowa();
return 0;
};
F.嘤嘤不想找最小喵
题意:给你一个数组,请你找个最小的k,满足a[i]+a[i+2k]=2*a[i+k] 1<=i<=n-2k
思路:满足的式子是等差数列,因此我们需要找一个k使得长度为n的数组为等差数列,等差数列有一个性质,三个数之间满足等差数列,任意长度相连的数也满足等差数列,则我们可以用哈希前缀和求
ac代码:
/* ʕ•̀ ω • ʔ *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍) ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿ *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽● ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
∩ ∩ ̋(๑˃́ꇴ˂̀๑) ᐕ)⁾⁾ *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
>(>_<)<
I I
I I ʕง•ᴥ•ʔง
IU UI
I I ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~) ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
*/
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
const int N = 5e5 + 10;
ull p[N], h[N];
int n;
ull get(ll l,ll r){
return h[r] - h[l - 1] * p[r - l + 1];
}
void Miraitowa(){
cin >> n;
p[0] = 1;
for (int i = 1; i <= n;i++){
ll x;
cin >> x;
p[i] = p[i - 1] * 13331;
h[i] = h[i - 1] * 13331 + x;
}
//要包含数组中所有的点,则第一个点为左边点能取到的范围,第二个为中间的点取到的范围,第三个为右边的点取到的范围
for (int i = 1; i <= n;i++)
if((get(1,n-2*i)-get(1+i,n-i))==(get(1+i,n-i)-get(1+2*i,n))){
cout << i << endl;
return;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
// int t;
// cin>>t;
// while(t--)
Miraitowa();
return 0;
};