跳到正文

个人记录

NOIP2025 广东迷惑行为大赏

ran_qwq约 71 分钟
原文
文章信息与版本

文章信息

发布
2025年12月12日
收录
2025年12月19日
更新
2026年11月16日
篇幅
约 71 分钟

版本

  1. v3当前
  2. v2
  3. v1

请一定不要在代码及代码注释里加入与考试无关的内容,包括:歌词、诗词、游记、感言等。特别注意:不要在代码及代码注释中加入有侮辱性、歧视性的语言、变量命名、函数命名等内容。

何意味啊。

让我们看看有这样的“特别提醒”的情况下,广东的选手们都整了些什么活吧。

本次 noip 一共 1390 人参加,整活人的比例与 csp2025 和 noip2024 相比都略有提高(可能是之前只搜索了关键词而不是地毯式搜索导致的),但是整体注释长度减少,那种大段大段的歌词、游记和感言数量大大减少。

不难看出,csps 分数越低(广东的 noip 准考证按照是否高中为第一关键字,csps 分数为第二关键字),整活人密度越高。

注意后面有 eps 个人不按准考证号排序,是进行其他关键词搜索得到的。

1. GD-0010(祝好)
C++
/*
OI 生涯要这样子结束了吗……
去年明明 AK 了 NOIP,今年怎么连 T2 都不会做
怎么会有这么搞笑的人啊
去年省选 CE 爆了 100,没进队
今年 NOIP 直接炸。
咋回事??
不甘心啊……
不甘心啊!!

要笑就笑吧。再会了。

100+20+48+40 @ 12:32
Farewell, OI.

upd: 想到了 tree 的 O(nm^2) @ 12:40。没写完。GG.
*/
2. GD-0065(注:省略若干行)
C++
/*
去年的GD-0228,但是炸了
//freopen("query.in","w",stdin);
//freopen("query.in","r",stdin);
//freopen("query.in","w",stdout);
//freopen("query1.in","r",stdin);
//freopen("query.in","w",stdin);
//freopen("query.in","r",stdin);
//freopen("query.in","w",stdout);
//freopen("query1.in","r",stdin);
//freopen("query.in","w",stdin);
//freopen("query.in","r",stdin);
//freopen("query.in","w",stdout);
//freopen("query1.in","r",stdin);
//freopen("query.in","w",stdin);
//freopen("query.in","r",stdin);
//freopen("query.in","w",stdout);
*/
3. GD-0071(每道题主函数后都加了 // Cellinia Texas.)
C++
signed main()
{
    fileio("candy.in","candy.out");
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    t=1;
    while(t--) work();
    return 0;
} // Cellinia Texas.
4. GD-0099
C++
/*
// freopen
失败至极
我没有成功在任何一场正赛上做出 T3
无论是CSP,NOIP,WC,APIO
全部全部全部
都没有做出来
现在大概是 100+100+8+45=253
能拿一等,这是肯定的
T2有点难啊,还是我想复杂了,和CSP一样,两个多小时才过掉
我不想放弃啊
加油啊
能不能,T3多拿一点分呢?
相信你自己
我先去上个厕所
记得放到虚拟机下面跑一下

欸对哦我去年CSP过了T3,所以还是有可能的
我怎么可能过掉这道题,不行不行(不是不可能)

我把 m=2 过掉了,有点难推广
继续拿分吧
12:32 了,我有点纠结要放虚拟机里还是继续拿分
但是我觉得15min时再丢吧

100+100+16+45=261
怎么比CSP还低

欸可以 dp 啊!
来不及了,写不完了
就这样吧
我尽力了
尽力了,那就可以了
毕竟。我还有一年
反正APIO大概可以去了
最后4分钟肉查代码吧
*/
5. GD-0129
C++
/*
0 1
5 5
483903342 335678433 241951671 241951671 251607302
*/
//庆祝上高中以来第一次在提高组难度的模拟赛或正赛不会 T2
//conguratulations(I forget how to spell this qwq) my first time have not solved the second problem of one contest which difficulty is close to NOIP after become a senior high school student
//AFOed.(2022.9~2025.11.29)
6. GD-0136

candy

C++
/*
8:37 虽然不能严格证明但是我先试试贪心
考场用不了 ctrl+/ *
* 又可以用了?
8:46 疑似正解想到
8:54 过所有阳历,但是大洋里不给满啊
*/

tree

C++
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);

    return 0;
}
/*
9:52 T2 没思路,来想这个,但是想到一个自己觉得没问题的想法,但是是 On 复杂度,根本对不上,不知道为什么??
9:57 手模样例2出问题
*/
7. GD-0233

sale

C++
/*
呜呜呜又炸掉了 一点思路都没有,连特殊性质都不会。。。
完蛋了。。。
*/
8. GD-0320
C++
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define _ 8005
ll n,a[_],q;
void solve() {
    cin>>n;
    for(ll i=1;i<=n;i++) cin>>a[i];
    cin>>q;
    while(q--) {
        ll L,R;
        cin>>L>>R;
        ull ans=0;
        for(ll i=1;i<=n;i++) {
            ll s=LONG_LONG_MIN;
            for(ll len=L;len<=R;len++) {
                for(ll l=max(1ll,i-len+1);l<=i;l++) {
                    ll r=l+len-1;
                    if(r>n) break;
                    ll sum=0;
                    for(ll j=l;j<=r;j++) sum+=a[j];
                    s=max(s,sum);
                }
            }
            // cout<<s<<endl;
            ans^=s*i;
        }
        cout<<ans<<'\n';
    }
}
int main() {
    freopen("query.in","r",stdin);
    freopen("query.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);solve();
    return 0;
}
/*
it's rainy
*/
9. GD-0323(我)
C++
/*
0 1
5 8
220765287 220765287 385102324 274559302 441530574

0 1
5 5
483903342 335678433 241951671 241951671 251607302

AFO.
*/
10. GD-0339
C++
/*
考前30min检查一次文件
不要发呆,对的你你的训练时间
*/
11. GD-0343
C++
/*
!noip@Nov29,2025:dream

4 20
3 4
2 7
2 8
1 8
*/
12. GD-0388
C++
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
long long c,t,n,a[5005],m,ans,fac[5005],inv[5005],dp[305][10005];
struct node{
	double aa;
	long long a,mem,id;
}sug[5005];
long long C(int x,int y)
{
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
long long qpow(long long x,int k)
{
	long long res=1;
	while(k)
	{
		if(k&1)res=res*x%mod;
		x=x*x%mod;
		k>>=1;
	}
	return res;
}
/*void Paco20()
{
	if(n==1)
	{
		cout<<2;
		return ;
	}
	sort(a+1,a+n+1);
	if(a[n]==a[n-1])
	{
		int res=2;
		for(int i=n-2;i>=1;i--)
		{
			if(a[i]!=a[i+1])break;
			res++;
		}
		for(int i=2;i<=res;i++)
			ans=(ans+C(res,i))%mod;
		//cout<<ans<<'\n';
		ans=qpow(2,n-res)*ans%mod;
	}
	else
	{
		int res=1;
		for(int i=n-2;i>=1;i--)
		{
			if(a[i]!=a[i+1])break;
			res++;
		}
		for(int i=1;i<=res;i++)
			ans=(ans+C(res,i))%mod;
		//cout<<C(1,1);
		//cout<<res<<endl;
		//cout<<ans<<'\n';
		ans=qpow(2,n-res)*ans%mod;
	}
	cout<<ans<<'\n';
	return ;
}*/
bool cmp(node x,node y)
{
	if(x.aa==y.aa)
	{
		if(x.a==y.a)return x.id<y.id;
		return x.a>y.a;
	}
	return x.aa>y.aa;
}
void PacoHelpisto()
{
	long long  res=0,maxx=0;
	long long cnt=0;
	for(int st=0;st<(1<<n);st++)
	{
		cnt=0,res=0;
		for(int i=0;i<n;i++)
		{
			sug[i+1].a=a[i+1],sug[i+1].id=i+1;
			if((st>>i)&1)sug[i+1].aa=(double)a[i+1]/2,sug[i+1].mem=2;
			else sug[i+1].aa=a[i+1],sug[i+1].mem=1;
		}
		sort(sug+1,sug+n+1,cmp);
		for(int i=1;i<=n;i++)
		{
			if(cnt+sug[i].mem>m)continue;
			res+=sug[i].a;
			cnt+=sug[i].mem;
			//cout<<mem[i]<<' '<<cnt<<'\n';
		}
		memset(dp,-1,sizeof(dp));
		dp[0][0]=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<=m;j++)
			{
				dp[i][j]=dp[i-1][j];
				if(j>=sug[i].mem and dp[i-1][j-sug[i].mem]!=-1)
					dp[i][j]=max(dp[i-1][j],dp[i-1][j-sug[i].mem]+sug[i].a);
			}
		}
		long long flfl=0;
		for(int i=1;i<=m;i++)flfl=max(flfl,dp[n][i]);
		//cout<<flfl<<' '<<res<<endl;
		if(flfl==res)ans++;
	}
	cout<<ans<<'\n';
	return ;
}
int main()
{
	ios::sync_with_stdio(0);
	cout.tie(0);
	freopen("sale.in","r",stdin);
	freopen("sale.out","w",stdout);
	cin>>c>>t;
	fac[0]=1;
	for(int i=1;i<=5000;i++)fac[i]=fac[i-1]*i%mod;
	inv[5000]=qpow(fac[5000],mod-2);
	for(int i=4999;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	//cout<<C(5,3);
	while(t--)
	{
		cin>>n>>m;
		ans=0;
		for(int i=1;i<=n;i++)cin>>a[i];
		//if(m==2)
		//{
			//Paco20();
			//continue;
		//}
		if(n<=300){
			PacoHelpisto();
			continue ;
		}
	}
	return 0;
}
13. GD-0462(代码末尾漏了个 /* 而 CE)
C++
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=1e4+5;
struct ooo
{
	int val;
	int id;
	int w;
}a[N+5],b[N+5];
int n,m;
long long ans;
bool cmp1(ooo aa,ooo bb)
{
	if(1.0*aa.val/aa.w!=1.0*bb.val/bb.w)
	return 1.0*aa.val/aa.w>1.0*bb.val/bb.w;
	if(1.0*aa.val!=1.0*bb.val)
	return aa.val>bb.val;
	return aa.id<bb.id;
}
bool cmp2(ooo aa,ooo bb)
{
	return aa.id<bb.id;
}
bool get_ans()
{
	sort(b+1,b+n+1,cmp1);
	long long s=m,sum=0;
	int fl=0;
	for(int i=1;i<=n;i++)
	{
//		cout<<b[i].val<<" "<<b[i].w<<endl;
		if(s-b[i].w>=0)
		s-=b[i].w;
		else
		{
			if(b[i].w==2&&s==1&&fl==0)
			fl=i;
		}
	}
//	cout<<endl;
//	cout<<fl<<endl;
	long long x1=0,x2=0;
	if(fl!=0)
	{
		for(int i=fl-1;i>=1;i--)
		{
			if(b[i].w==1)
			{
				x1=b[i].val;
				break;
			}
		}
		for(int i=fl+1;i<=n;i++)
		{
			if(b[i].w==1)
			{
				x2=b[i].val;
				break;
			}
		}
//			cout<<"bbbbbbbbbb"<<fl<<" "<<x1<<" "<<x2<<endl;

		if(x1+x2<b[fl].val)
		{
//			cout<<"aaaaaa";
			return 0;
		}
	}
	return 1;
}
void dfs(int x,int d)
{
	a[x].w=d;
	if(x==n)
	{
		for(int i=1;i<=n;i++)
		{
			b[i]=a[i];
		}
		if(get_ans())
		ans++;
		return;
	}
	dfs(x+1,1);
	dfs(x+1,2);
}
int main()
{
	freopen("sale.in","r",stdin);
	freopen("sale.out","w",stdout);
	int l,t;
	cin>>l>>t;
	while(t--)
	{

	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		a[i]=(ooo){x,i,1};
	}
	ans=0;
	dfs(0,1);
	cout<<ans<<endl;
	}
	return 0;
}
/*
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=1e4+5;
struct ooo
{
	int val;
	int id;
	int w;
}a[N+5];
int n,m;
long long C[1005][1005],mod=998244353,ans;
void bef()
{
	C[0][0]=1;
	for(int i=1;i<=100;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			C[i][j]=C[i-1][j-1]+C[i-1][j];
			C[i][j]%=mod;
		}
	}
}
bool cmp1(ooo aa,ooo bb)
{
	if(1.0*aa.val/aa.w!=1.0*bb.val/bb.w)
	return 1.0*aa.val/aa.w>1.0*bb.val/bb.w;
	if(1.0*aa.val!=1.0*bb.val)
	return aa.val>bb.val;
	return aa.id<bb.id;
}
bool cmp2(ooo aa,ooo bb)
{
	return aa.id<bb.id;
}
int get_id(int k)
{
	for(int i=1;i<=n;i++)
	if(a[i].id==k)
	return i;
	return 0;
}
void clean1()
{
	for(int i=1;i<=n;i++)
	a[i].w=1;
}
int check(int x)
{
	for(int i=1;i<=5;i++)
	cout<<i<<":"<<a[i].val<<" "<<a[i].w<<endl;
	bool fl1=0,fl2=1;
	int t1,t2=n+1;
	for(int i=1;i<x;i++)
	{
		if(a[i].w==1)
		fl1=1,t1=i;
	}
	for(int i=n;i>x;i--)
	{
		if(a[i].w==1)
		fl2=1,t2=i;
	}
	//
	if(fl1==0||fl2==0)
	return 0;
	if(a[t1].val+a[t2].val>=a[x].val)
	{
		a[t1].w=2;
		return 2;
	}
	cout<<"t1t2:"<<t1<<" "<<t2<<endl;
	for(int i=x+1;i<t2;i++)
	{
		if(a[i].val>=a[t1].val+a[t2].val)
		{
			a[t1].w=2;
			return 2;
		}
	}
	int cnt1=0,cnt2=0;
	for(int i=1;i<t1;i++)
	{
		if(1.0*a[i].val/2>1.0*a[x].val/2||(1.0*a[i].val/2==1.0*a[x].val/2&&a[i].id<a[x].id))
		{
			cnt1++;
		}
		else
		if(a[i].val>=a[t1].val+a[t2].val)
		{

		}
		else
		{
			cnt2++;
		}
	}
	a[t1].w=2;
	int delta=(m-2)-(t1-1);
	cout<<cnt1<<" "<<cnt2<<" "<<delta<<endl;
	for(int i=0;i<=cnt1;i++)
	{
		if(i>=0&&i-delta>=0&&i-delta<=cnt2)
		ans+=C[cnt1][i]*C[cnt2][i-delta]*pow(2,n-t2+1);
	}
	cout<<"ans"<<" "<<ans<<endl;
	return 1;
}
void do_it(int k)
{
	int x;
	sort(a+1,a+n+1,cmp1);
	x=get_id(k);
	cout<<k<<endl;
		cout<<"a"<<endl;
	while(check(x)!=0)
	{
		sort(a+1,a+n+1,cmp1);
		x=get_id(k);
	}
}
int main()
{
	bef();
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		a[i]=(ooo){x,i,1};
	}
	for(int i=1;i<=n;i++)
	{
		clean1();
		a[i].w++;
		do_it(i);
		sort(a+1,a+n+1,cmp2);
	}
	cout<<pow(2,n)-ans;
	return 0;
}
最后一场比赛了,安息吧,多做自己喜欢做的事情吧
mug
2025 11 29 深圳
高三最后一年了,好好休息,要有清醒的头脑,才好去思考,去做事情嘛
还有警惕泥潭
非曰能之,愿学焉
14. GD-0539
C++
int main(){
	freopen("sale.in","r",stdin);
	freopen("sale.out","w",stdout);
//	work();
//	return 0;
	cin>>cid>>T;
	while(T--){
		work();
	}
	return 0;
}/*
5 5
4839 3356 2516 2419 2419
最后发现暴力还挂了
印象中我检查了,但好像事实就是没检查
*/
15. GD-0562
代码
/*
8:35 尝试使用dp求解,但是注意到dp很难记录现在是第几颗糖
9:08 尝试贪心求解,按照 x+y 排序
    买空最便宜的x+y,多余的钱按照x排序购买
    正确性证明:
        反证法,买空如果不买最便宜的 x+y,那答案是不优的
        剩下的钱一定不够再买两颗一样的,按照 x 花完剩下的钱即可
9:23 WA了5,6,7
    主要思路正确,但是可以尝试不买若干个,换成买一个x
9:59 Windows 下 AC 所有样例
10:04 Linux 下 AC 所有样例
AC咯! *★,°*:.☆( ̄▽ ̄)/$:*.°★* 。
*/
16. GD-0571
C++
#include<bits/stdc++.h>
/*
#include<windows.h
*/
/*
#include<bits\stdc++.h>
*/
#define int long long
using namespace std;
int n,m,an,cha,chb;
const int N=100005;
struct candy
{
	int x,y;
}nn[N];
/* TODO (#1#): B havnt been done */
/* TODO (#2#): maybe greedy,not dp
               need time */
/* TODO (#-10000000#): mihuoxingweidashang
               freopen
               main
               bits */
bool us[N];
void dfs(int s1,int s2)
{
	if(s1>m)
	{
		return;
	}
	an=max(an,s2);
	for(int i=1;i<=n;i++)
	{
		if(!us[i])
		{
			if(m-s1>=nn[i].x)
			{
				us[i]=1;
				dfs(s1+nn[i].x,s2+1);
				us[i]=0;
			}
		}
		else
		{
			if(m-s1>=nn[i].y)
			{
				us[i]=0;
				dfs(s1+nn[i].y,s2+1);
				us[i]=1;
			}
		}
	}
}
bool cmpA(candy A,candy B)
{
	return A.x<B.x;
}
void solveA()
{
	sort(nn+1,nn+n+1,cmpA);
	an=(m*1/nn[1].x);
 }
bool cmpB(candy A,candy B)
{
	return ((A.x-A.y)==(B.x-B.y)?A.x<B.x:(A.x-A.y)<(B.x-B.y));
}
void solveB()
{
	sort(nn+1,nn+n+1,cmpB);
	int ne=0;
	for(int i=1;i<=n;i++)
	{
		ne+=(nn[i].x+nn[i].y);
		an+=2;
		if(ne>m)
		{
			break;
		}
	}
	if(ne>m)
	{
		return;
	}
	an*=(m*1/ne);
	ne*=(m*1/ne);
	for(int i=1;i<=n;i++)
	{
		ne+=(nn[i].x+nn[i].y);
		an+=2;
		if(ne>m)
		{
			break;
		}
	}
}
signed main()
/*
int mian()
*/
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	//freopen("candy.in","r",stdin);
	//freopen("candy.out","w",stdout);
	//freopen("candy.out","w",stdin);
	//freopen("candy.in","r",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>nn[i].x>>nn[i].y;
		if(nn[i].x!=nn[i].y)
		{
			cha=1;
		}
		if(nn[i].x<nn[i].y)
		{
			chb=1;
		}
	}
	if(cha)
	{
		dfs(0,0);
	}
	else
	{
		solveA();
	}
	cout<<an;
	return 0;
}
C++
#include<bits/stdc++.h>
/*
#include<windows.h
*/
#define int long long
using namespace std;
int n,m;
int an()
{
	int x=rand();
	return (x<1024?x:an());
}
signed main()
{
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	for(cin>>n;n;n--)
	{
		cin>>m;
	}
	srand(time(0));
	for(cin>>m;m;m--)
	{
		cout<<an();
	}
	return 0;
}
17. GD-0572(同学,你的文操呢?)
C++
# include<cstdio>
# include<cstring>
# include<iostream>
# define ll long long
const int N=5e3+10,MOD=998244353;
using namespace std;
int c,T;
int n,m,a[N];
bool cmp(int x,int y) {
	return x>y;
}
ll KSM(ll x,ll y) {
	ll res=1;
	while(y) {
		if(y&1) (res*=x)%=MOD;
		y>>=1;
		(x*=x)%=MOD;
	}
	return res;
}
int main() {
	scanf("%d%d",&c,&T);
	/*
	if(c>=1 && c<=5) {
		//����

		dfs(1);
	}*/
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	printf("%lld",KSM(2,n)%MOD);
	return 0;
}
18. GD-0659 O(nlogn) tree,此人dp打成pd CE
C++
#include<bits/stdc++.h>
using namespace std;
struct point{
	int f,ss,depth;
	vector<int>son;
}tree[10000];
long long ans1=0;
bool pd[100000];
void tj(const int a){
	tree[a].ss++;
	if(tree[a].f!=a&&tree[a].f!=0&&a!=0)tj(tree[a].f);
}
bool cmp(const int a,const int b){
	return tree[a].ss>tree[b].ss;
}
int dp(const int a){

	return tree[a].ss+1;
	if(tree[a].ss>0){
		int max1=0,sum=0;
		for(int i=0;i<tree[a].ss;i++){
			if(tree[tree[a].son[i]].ss>0){
				sum+=dp(tree[a].son[i]);
			}else{
				max1+=1;
			}
		}
		return tree[a].ss+1+dp(max1);
	}
	return 1;
}
int dfs(const int a){
	int v=1;
	if(tree[a].ss>0){
		for(int i=0;i<tree[a].ss;i++){
			if(tree[tree[a].son[i]].ss>0){
				ans1+=dfs(tree[a].son[i]);
			}else{
				v+=1;
			}
		}
	}
	return v;
}
int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	int n,t;
	int m,sum=0,tmp,mxdp,mx;
	scanf("%d",&t);
	while(t--){
		mxdp=0;
		mx=1;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++){
			tree[i]={1,0,1};
			pd[i]=0;

		}
		for(int i=2;i<=n;i++){
			scanf("%d",&tmp);
			tree[i].f=tmp;
			pd[tmp]=1;
			tree[i].depth=tree[tmp].depth+1;
			mxdp=max(mxdp,tree[i].depth);
			//tree[tmp].son.push_back(i);
			tj(tree[i].f);
		}
		for(int i=1;i<=n;i++){
			if(!pd[i]){
				mx+=tree[i].depth;
			}
		}
		//ans1+=dfs(1);
		printf("%lld\n",pd(1));
		//ans1=0;
	}
	return 0;
}
/*
本题思维:
观察到,树的价值为1<=i<=n的s_i之和,
s_i为结点i的子树中不存在的最小的非零整数
贪心策略?
树型DP?
由于数据量达到了8000,推测做法复杂度为n^2
树的高度最高为800,是否有提示?
!!!!每次选择最长链即可!
用O(nlogn)复杂度找到最优解法,最长链
记得初始化
2
5 2
1 1 2 2
7 2
1 1 2 2 2 3
*/
19. GD-0664 RUNNNING FINNNALLY
C++
//#include<bits/stdc++.h>
//using namespace std;
//const int N=1e6;
//int v[N],w[N];
//int dp[N];
//int main()
//{
//	int n,m;cin>>n>>m;//n个物品,m容量
//	for(int i=1;i<=n;i++)cin>>v[i]>>w[i];
//	for(int i=1;i<=n;i++)
//	{
//		for(int j=m;j>=w[i];j--)
//		{
//			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
//		}
//	}
//	cout<<dp[m];
//}
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6;
int n,m;
int v[N],w[N];
int dp[N];
struct node{
	int v,w;
	int id;
};
node arr[N];
int ksm(int a,int b)
{
	int res=1;
	while(b!=0)
	{
		if(b%2==1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
void init(int x)
{
//	printf("WAITING------\n");
	for(int i=1;i<=n;i++)
	{
		w[i]=x%2+1;
//		printf("i=%d w[i]=%d\n",i,w[i]);
		x/=2;
	}
}
void dps()
{
//	printf("RUNNNING!!!!!!\n");
//	for(int i=1;i<=n;i++)
//	{
//		cout<<v[i]<<" "<<w[i]<<endl;
//	}
	for(int i=0;i<=m+1;i++)dp[i]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=m;j>=w[i];j--)
		{
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
//	cout<<dp[m]<<endl;
//	printf("FINNNALLY\n");
	//dp[m]存着在当前w下的最大原价
}
int sum=1;
bool cmp(node a,node b)
{
	if((sum/a.w*a.v)==(sum/b.w*b.v))
	{
		if(a.v==b.v)return a.id<b.id;
		else return a.v>b.v;
	}
	else return (sum/a.w*a.v)>(sum/b.w*b.v);
}
int moni()
{
	sum=1;
	for(int i=1;i<=n;i++)
	{
		arr[i].v=v[i];
		arr[i].w=w[i];
		arr[i].id=i;
		sum*=w[i];
//		printf("arr[%d].v=%d  arr[%d].w=%d\n",i,arr[i].v,i,arr[i].w);
	}
	int lm=m;
	sort(arr+1,arr+1+n,cmp);
//	for(int i=1;i<=n;i++)
//	{
//		cout<<arr[i].id<<" ";
//	}
//	cout<<endl;
	int cost=0;
	for(int i=1;i<=n;i++)
	{
		if(lm>=arr[i].w)
		{
			cost+=arr[i].v;
			lm-=arr[i].w;
		}
	}
	return cost;
}
void solveA()
{
	cout<<ksm(2,n)<<endl;
}
void solve()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>v[i];
	int a=v[1];bool fl=0;
	for(int i=1;i<=n;i++)
	{
		if(v[i]!=a)fl=1;
	}
	if(fl==0)
	{
		solveA();
		return ;
	}
	int cnt=0;
//	cout<<ksm(2,n);
	int res=0;
	for(int i=1;i<=ksm(2,n);i++)
	{
		init(cnt);
//		for(int j=n;j>=1;j--)cout<<w[j]<<" ";
//		cout<<endl;
		cnt++;
		dps();
//		printf("LAST--------\n");
//		cout<<dp[m]<<" "<<moni()<<endl;
		if(dp[m]==moni())
		{
			res++;
		}
	}
	cout<<res%998244353<<endl;
}
signed main()
{
//	freopen("D:\\GD-0664\\sale\\sale2.in","r",stdin);
//	freopen("D:\\GD-0664\\sale\\rrrrres.out","w",stdout);
	freopen("sale.in","r",stdin);
	freopen("sale.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int c,t;cin>>c>>t;
	while(t--)
	{
		solve();
	}
 }
/*
0 1
3 2
1 3 5
*/
20. GD-0694
C++
/*
枚举
二分
控分
排列

*/
21. GD-0707 hyw
C++
#include<bits/stdc++.h>
using namespace std;
const int N = 8010, M = 800;
int n, m, t, S[N], dot_size[N], dot_h[N], num_son[N];
vector<int> son[N];

bool cmp(int a, int b){
	return dot_size[a] > dot_size[b];
}

int pre_dfs(int rot){// 预处理,给每个点计算其子树的大小,并将点的孩子按照子树大小排好序
	dot_size[rot] = 1;
	for(int i = 0; i < son[rot].size()-1; i++){
		dot_size[rot] += pre_dfs(son[rot][i]);
	}
	sort(son[rot].begin(), son[rot].end(), cmp);
	return dot_size[rot];
}

void work_dfs(int rot, int pre_fa, int last_bro){
	int pre_bro = -1;
	for(int i = 0; i < son[rot].size(); i++){
		work_dfs(son[rot][i], rot, pre_bro);// 先将子树递归下去
		pre_bro = son[rot][i];
	}
	//现在已经将rot的子树全部解决
	if(son[rot].size() == 0){// 若它是叶子节点
		S[rot] = -1;// 没有集合
	}

	// 选择对齐左边节点:
	if(last_bro != -1) {
		S[rot] = S[son[rot][i]] + 1;
		work_dfs()
	}
	work_dfs()

}


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	freopen("tree.in", "r", stdin);
	freopen("tree.out", "w", stdout);

	cin >> t;
	while(t--){
		cin >> n >> m;
		for(int i = 2; i <= m; i++){
			int hyw;
			cin >> hyw;
			son[hyw].push_back();
		}
		dot_size[1] = pre_dfs(1);
		memset(S, -1, sizeof S);
		// 此时已经处理好

		// 主算法:思路:
		/*
			上面已经进行了预处理
			接下来
			进行前序遍历,子树较大的孩子先计算
			后面的孩子有两个选择:{
				将权值定为它子树集合S[i]中,不在集合S[i]中的最小非负整数;
				将权值定位它父亲节点S[pi]中。。。。整数
			DFS枚举
			能拿30分
		*/
		work_dfs(rot);

	}


	return 0;
}
22. GD-0718《not sha**》《ccf i love you》《假装做了这题》
C++
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, m;
struct candy {
	int x, y;
} a[100010];
int sa1;
bool cmp1(candy A, candy B) {
	return A.x + A.y < B.x + B.y;
}
int b[100010], _;
bool ts1;
int sb; //sum of b[], not sha**.
int ans;
signed main() {
	freopen("candy.in", "r", stdin);
	freopen("candy.out", "w", stdout);
	cin >> n >> m;
	ts1 = true;
	for(int i = 1; i <= n; i++) {
		cin >> a[i].x >> a[i].y;
		if(a[i].x != a[i].y) ts1 = false;
	}
	sort(a + 1, a + n + 1, cmp1);
	if(ts1) {
		cout << m / a[1].x << endl;
		return 0;
	}
	for(int i = 1; i <= n; i++) {
		b[i] = a[i].x;
	}
	sort(b + 1, b + n + 1);
	sa1 = a[1].x + a[1].y;
	for(int i = 0; i <= n; i++) {
		sb += b[i];
		if(m < sb) break;
		ans = max(ans, (m - sb) / sa1 * 2 + i);
	}
	cout << ans << endl;
	return 0;
}
/*
ccf i love you
please give me the 1=jiang
*/
C++
/*
放个 cpp 在这假装我做了这道题。
*/
#include<bits/stdc++.h>
//#define int long long
using namespace std;

signed main() {
	freopen("query.in", "r", stdin);
	freopen("query.out", "w", stdout);
	return 0;
}
23. GD-0733 复制题面人
C++
/*
糖果店剩下了 n 颗糖果,其中第 i (1 ≤ i ≤ n)颗糖果的原价为 ai 元。
全部重新定价。
具体地,将每颗糖果的清仓价格分别定为 1 元或 2 元。
设第 i (1 ≤ i ≤ n) 颗糖果的清仓价格为wi ∈ {1, 2} 元,则它的性. 价. 比. 被定义为原价与清仓价格的比值,即 ai/wi。
 m 元钱买糖果。希望他购买到的糖果的原价总和最大,
于是他采用了以下购买策略:将所有糖果按照性. 价. 比. 从. 大. 到. 小. 排. 序. ,然后依次考虑每一颗糖果。
具体地,在考虑第 i (1 ≤ i ≤ n) 颗糖果时剩余的钱至少为 wi 元,则他会购买这颗糖果,否则他会跳过这颗糖果,继续考虑下一颗。
特别地,若存在两颗糖果的性价比相同,则先考虑原. 价. 较. 高. 的糖果;若存在两颗糖果的性价比与原价均相同,则先考虑编号较小的糖果。

例如,若小 X 的糖果商店剩余 3 颗糖果,原价分别为 a1 = 1,a2 = 3,a3 = 5,而清仓价格分别为 w1 = w2 = 1,w3 = 2,则性价比分别为 1, 3, 5/2。
因此会先考虑第2 颗糖果,然后考虑第 3 颗糖果,最后考虑第 1 颗糖果。
小 R 想知道,在小 X 的所有 2n 种定价方案中,有多少种定价方案使得他按照上述购买策略能购买到的糖果的原. 价. 总. 和. 最. 大. 。
你需要帮助小 R 求出满足要求的定价方案的数量。
由于答案可能较大,你只需要求出答案对 998, 244, 353 取模后的结果
*/
24. GD-0767 AFOing
C++
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;

int c,t;
int dp[10][10];// dp_mask,i
int qow2[5010];

int main(){
	freopen("sale.in","r",stdin);
	freopen("sale.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	qow2[0]=1;
	for(int i=1;i<=5000;i++) qow2[i]=(qow2[i-1]*2)%mod;
	cin>>c>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		vector<int> a;
		for(int i=1;i<=n;i++){
			cin>>x;
			a.push_back(x);
		}

		if(c==18) {
			cout<<qow2[n]<<endl;
			continue;
		}
		else{
			cout<<0<<endl;
		}
	}

	return 0;
}

/*
10:18 T2这个题面描述有点诡异 看懂了 暴力几乎是不可做的
首先要发现小R在贪心的买东西 我们要找到贪心策略不优时的情况数 容斥一下
这个dp方程到底怎么写 好绝望
10:53 推了半小时T3没有结果
10:58 T2是状压dp? 今年这个T1过于一眼1=分数线应该会高
12:03 好绝望。AFOing 写不出来的话就只能退役了啊 目前预估得分110 这连22年1=线都没有的分数。

*/
25. GD-0786 MC大神
C++
/*
4 18
4 5
2 10
3 13
1 100
ans=5
*/
/*
GD-*7*6
Luogu uid=753204;
username:mywzj_mo
DH's computers are worse than SZgz.
Password:!noip@Nov29,2025:dream

Hey!Someone is looking me!
Are you here?
How do you think 2n0o2i5p[don't write key word]?
Yeah,I guess you think it is easier than last year.
I agree to you opinion.
Have a good time!See you in next code.
*/
C++
/*
Don't want to write anything.

Theresmore is a game to play.
Changed x Minecraft:
changed:latexgrowspeed=10
changed:keepform=true
Player [Luogu uid=753204] is transfured by Dark Latex wolf.
/clear (Clear 114514 emptys.)


AFO.And,to learn art and music to create a game.
*/
C++
/*
Luogu uid=753204.More info in "candy.cpp"

Codes are Normal.

But I unable to complete it.

Which one(or more)do you know?
Catnap(hobby's gametime 3)
Alan_Walker(?)
Ori
Creeper(?,from minecraft)
Colin(Changed,Changed-special)
Freddy(FNAF)

The Smart you must can find the secret in words.
*/
C++
/*
Wang la!
Hao silly am I!
This year is over!


Luogu 3k kkk_sc03
Luogu cz chen_zhe
Luogu xht
Luogu no*p
Luogu UKE ***************
Luogu IDE(lost)
Luogu Traning
Luogu blog
Luogu Accepted
Luogu TLE
Luogu MLE
Luogu Wrong answer
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
Luogu
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
freeopen
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
sto,orz,afo,
cnt_broken=3;

I am furry lover!
Puro!
*/
26. GD-0807 happy birthday
C++
/*
11-29 lza happy birthday
rp++
*/
代码
27. GD-0815
C++
//不要被误导了去用dp
//贪心才是正解
//比s组T1简单
28. GD-0823 ???神人代码
C++
#include<bits/stdc++.h>
#define ccf int
#define b(x) int x=114
#define c e
#define s(x) cout<<(x)
#define v "understand!"
#define d loop
#define f <=
#define g 911
#define z(x) if(x)
#define tree "query.out"
#define k goto
#define a freopen
#define q "I "
#define w "don't "
#define t 1145
#define GZ(x) a(x,n,stdout)
#define u 2025
#define dfs main
#define o 114514
#define candy "query.in"
#define h "r"
#define n "w"
#define CN(x) a(x,h,stdin)
#define m ==
#define kkk(x) c m x
using namespace std;
ccf dfs(){
	CN(candy);
	GZ(tree);
	b(c);
	d :
	z(kkk(g)){
		s(q);
	}
	z(kkk(t)){
		s(w);
	}
	z(kkk(u)){
		s(v);
	}
	c++;
	z(c f o){
		k d;
	}
}
//I don't understand!
//过去了一个小时,T1还是没写出来
//四个半小时死磕T1(因为其他题都看不懂(首 首 首))
//打暴力骗分吧qwq
//来钓鱼
/*
#include<bits\stdc++.h>;
using name space stb
itn mian(void ccf){
	freoden("cand.in",'w',std.ans);
	fropen("camdy.out",'r',cin);
	retrun 114;
}
*/
//T1都做不出来 我也是彻底完蛋了
//还感冒了,头晕晕的awa
//旁边dalao打代码咔咔响,吵死了
//今年没了,明年再来吧
//不知道会不会上洛谷hhh
29. GD-1049 拼好分
C++
/*
52pts
拼好分!
*/
30. GD-1051
C++
/*
30min写完(到9:15)
long long 1 2
数组 1 2
freopen 1 2
文件名 1 2
函数返回值 1 2
Windows大样例 1 2
Linux大样例 1
txt提交的文件 1 2

g++ candy.cpp -o candy.exe -O2 -std=c++14 -static -Wall
candy.exe

*/
31. GD-1106 又是你?
C++
/*
rto Zyj6 orz
rto YY0707 orz
rto Skyler_Yunxi orz
rto nauyng orz
rto huangpintao orz
rto less_than orz
rto greater_than orz
rto AUSG orz
rto Hanson2024 orz
rto JXR_Kalcium orz
rto chjh orz
rto gongruixin orz
*/
32. GD-1199 掉了
C++
/*
掉了....
最后7分钟就这样吧。
*/
33. GD-1204 颗秒!
C++
/*
第一题A了
颗秒!
*/
34. GD-1257 遗憾离场
C++
// 9:49 20pts
//12:46 ~20pts
/*
再见了,OI
140pts 遗憾离场
*/
35. GD-1280 大学习
C++
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N=1e5+5;

signed main(){

	//freopen("query.in","r",stdin);
	//freopen("query.out","w",stdout);

	ios::sync_with_stdio(false);
	cin.tie(0);

	cout<<"已完成今日对于每次询问,设包含 i (1 ≤ i ≤ n) 的极好区间的最大权值为 ki,输出一行一个非负整数,表示 ⊕n i=1 ((i × ki) mod 2 64),其中 ⊕ 表示二. 进. 制. 按. 位. 异. 或. 。注意:对于任意整. 数.x,存在唯. 一. 的. 非. 负. 整. 数.x′ 满足 x′ ≡ x (mod 2 64) 且 0 ≤ x ′ ≤ 2 64 ? 1,则记x mod 2 64 = x大学习";

	return 0;

}
/*
我们必须想象被形式化输出格式卡住不能写暴力的OIer是幸福的。
报告长官,这太难了,我做不到!
那就去猛击自己魔丸325下!
苦也,这也言周?
*/
36. GD-1291 恭喜接广(此代码一共三千行,7w 字节,省略了重复内容)
C++
//#include<bits\stdc++.h>
//froepen(
//slove
//freopen("candy.ans","r",stdout);
C++
The length is a secret

I love CCF very much!
Can you help me ac test 6?
My answer is smaller than CCF's
I can't believe my code is wrong
I debug it for 2 hours
I want to cry
It's a bad experience
I want to 100+
I don't want to 0
Please tell me how to accepted this question
Please take me to 迷惑行为大赏
And tell me what's wrong with this code

1291 is a bad number
91 is a bad Ad
I don't want to look 91 again
It's bad in luck
I just have 1 year
Don't say "恭喜接广"
I will be sad if you do that
91 don't give me money at any time

 I love CCF very much!
Can you help me ac test 6?
My answer is smaller than CCF's
I can't believe my code is wrong
I debug it for 2 hours
I want to cry
It's a bad experience
I want to 100+
I don't want to 0
Please tell me how to accepted this question
Please take me to 迷惑行为大赏
And tell me what's wrong with this code
37. GD-1295 崩铁启动
C++
//T3
#include<iostream>
#include<vector>
using namespace std;
const int si=8e3+10;
int n,m;
int fa[si];//父亲
vector<int> son[si];//儿子
int size[si];//子树大小
int an[si];//自己做根最大值
int l[si];//重链长度
int s[si];//重儿子
int ql[si];//奇链长度
int qs[si];//奇儿子
int cal(int p,int cnt){
	if(qs[p]==-1)return cnt;
	int re=cal(qs[p],cnt+1)+cnt;
	//if(p==6)cout<<re<<' '<<cnt<<'\n';
	for(auto u:son[p]){
		if(u==qs[p])continue;
		re+=max(an[u],size[u]*cnt);
	}return re;
}
void dfs(int p){
	s[p]=-1;
	size[p]=l[p]=an[p]=1;
	for(auto u:son[p]){
		dfs(u);
		size[p]+=size[u];
		if(l[u]+1>l[p]){
			l[p]=l[u]+1;
			s[p]=u;
		}
	}
	qs[p]=-1,ql[p]=l[p];
	int ls=0;
	for(auto u:son[p]){
		if(u==s[p])continue;
		if(ql[u]+l[p]>ql[p]){
			ql[p]=ql[u]+l[p];
			qs[p]=u;
		}
		ls=max(ls,l[u]);
	}
	//奇是重
	if(ls+ql[s[p]]+1>ql[p]){
		ql[p]=ls+ql[s[p]]+1;
		qs[p]=s[p];
	}
	if(son[p].size()==1){
		ql[p]=ql[son[p][0]]+1;
		qs[p]=s[p];
	}
	an[p]=cal(p,1);
}
int mian(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		son[i].clear();
	for(int i=2;i<=n;i++){
		scanf("%d",&fa[i]);
		son[fa[i]].push_back(i);
	}dfs(1);
	//for(int i=1;i<=n;i++)
	//	printf("%d %d %d %d\n",i,qs[i],ql[i],an[i]);
	cout<<an[1]<<'\n';
	return 0;
}
int t;
int main(){
	freopen("tree.in","r",stdin);
	freopen("tree.out","w",stdout);
	scanf("%d",&t);
	while(t--)mian();
	return 0;
}

/*
10:30 这是重链剖分吗
11:00 怎么实现......会做不会写
11:30 我不信了!我要跟它死磕到底!!!
12:00 奇链,昔涟。railway启动!!!
12:30 冲冲冲!!!debuging;
	  I feel tired. Who can help me? :(
*/
38. GD-1305 how to unique
C++
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;
const int N=2e6+10,inf=0x3f3f3f3f,mod=998244353;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
/*

*/
int n,m,a[N],c;
int quickMi(int a,int b){
	int res=1ll;
	while(b){
		if(b&1) res=(res*a)%mod;
		a=a*a%mod,b>>=1;
	}
	return res;
}
pii p[N];
int f[N];
bool cmp (pii x,pii y) {return x.x==y.x?x.y>y.y:x.x>y.x;}
void case1(){
	int cnt=0;
	for(int i=0;i<=(1ll<<n)-1ll;i++){
		for(int j=0;j<n;j++){ p[j]={a[j],0};
			if((i>>j)&1) p[j].y=1;
			p[j].y++,p[j].x*=(3-p[j].y);
		}
		sort(p,p+n,cmp);
		int res=0,l=m;
		for(int j=0;j<n;j++){
			//cout<<p[j].y<<" "<<p[j].x/(3-p[j].y)<<"\n";
			if(l<p[j].y) continue;
			l-=p[j].y,res+=p[j].x/(3-p[j].y);
		}
		int tres=0;
		for(int j=0;j<=m;j++) f[j]=0;
		for(int j=0;j<n;j++)
			for(int k=m;k>=p[j].y;k--)
				f[k]=max(f[k-p[j].y]+p[j].x/(3-p[j].y),f[k]);
		for(int j=0;j<=m;j++) tres=max(tres,f[j]);
		//cout<<tres<<" "<<res<<"\n";
		if(tres==res) ++cnt;
	}
	cout<<cnt%mod<<"\n";
}
void case2(){
	//wait, How to unique?
}
void mian(){
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>a[i];
	if(n<=10) case1();
	else if(c==16||c==18) cout<<quickMi(2,n)<<"\n";
	else if(m==2) case2();
}
signed main(){
	freopen("sale.in","r",stdin);
	freopen("sale.out","w",stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	int T=1;cin>>c>>T;
	while(T--) mian();
	return 0;
}
39. GD-1122 诈骗
C++
// froepen frepoen freepon 1774140
40. GD-0592 struct CCF
C++
struct ccf{int x,y,id;}xld[N];
bool cmp(ccf pre,ccf nxt){
  if(pre.x*nxt.y==nxt.x*pre.y){
    if(pre.x==nxt.x) return pre.id<nxt.id;
    else return pre.x>nxt.x;
  }else return pre.x*nxt.y>nxt.x*pre.y;
}
41. GD-0716 int ccf=0;
C++
#include<bits/extc++.h>
using int64=long long;
using float64=double;
using float128=long double;
constexpr int p = 998244353;
int dp[100],n,m,c[100],val[100],t;
struct A{
	long double a,b;
	bool operator<(const A other) const {
		return a<other.a;
	}
};
std::vector<A> v;
int dfs(int k){
	if(k==n+1){
			std::fill(dp,dp+m+1,0);
			for(int i=1;i<=n;i++){
				for(int j=m;j>=1;j--){
					if(c[i]==1&&j>=1){
						dp[j]=std::max(dp[j],dp[j-1]+val[i]);
					}else if(c[i]==2&&j>=2){
						dp[j]=std::max(dp[j],dp[j-2]+val[i]);
					}
				}
			}
			int sth=m;
			int result=0;
			for(int i=0,j=0;i<n&&j<n;){
				if(i==j){
					if(c[i]==1){
						j++;
					}else{
						i++;
					}
				}
				else if(v.at(i).a>v.at(j).b){
					i++;
					if(sth<1)continue;
					sth-=1;
					result+=val[i-1+1];

				}else{
					j++;
					if(sth<2)continue;
					sth-=2;
					result+=val[j-1+1];

				}
			}
//			std::cout<<dp[m]<<' '<<result<<'\n';
			if (dp[m]!=result){
				return 1;
			}else{
				return 0;
			}
	}
	int ans=0;
	for(c[k]=1;c[k]<=2;c[k]++){
		ans+=dfs(k+1);
	}
//	std::cout<<"sadadsa\n";
	return ans%p;
}
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	#ifndef DEBUG
	freopen("sale.in","r",stdin);
	freopen("sale.out","w",stdout);
	#endif
	int ccf=0;
	std::cin>>ccf>>t;
	for(int o=1;o<=t;o++){
		std::cin>>n>>m;
		v.clear();
		for(int i=1;i<=n;i++){
			std::cin>>val[i];
			v.push_back({val[i],val[i]/2});
		}
		std::sort(v.begin(),v.end(),std::less<A>());
		std::cout<<(int(pow(2,n))%p-dfs(1)+p)%p<<'\n';
	}


	return 0;
}
42. GD-0390&GD-0775 rp++
C++
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fir first
#define sec second
#define pii pair<int,int>
const int N=5e4+7;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;

void inputtt(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
}

int n;

int a[N];
ll ans[N<<2];

inline int ls(int x){
	return x<<1;
}inline int rs(int x){
	return x<<1|1;
}
void push_up(int x){
	ans[x]=ans[ls(x)]+ans[rs(x)];
}

void build(int x,int l,int r){
	if(l==r){
		ans[x]=a[l];
		return;
	}

	int mid=l+r>>1;
	build(ls(x),l,mid);
	build(rs(x),mid+1,r);
	push_up(x);
}

ll query(int x,int l,int r,int nl,int nr){
	if(nl<=l&&r<=nr){
		return ans[x];
	}

	int mid=l+r>>1;
	ll res=0;
	if(nl<=mid)res+=query(ls(x),l,mid,nl,nr);
	if(mid<nr)res+=query(rs(x),mid+1,r,nl,nr);
	return res;

}

int main(){

	inputtt();

	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int q;
	cin>>q;
	for(int rp=1;rp<=q;rp++){
		int l,r;
		scanf("%d%d",&l,&r);

		unsigned ll ans=0;

		for(int i=1;i<=n;i++){
			ll maxx=0;
			for(int j=1;j<=i;j++){
				for(int k=i;k<=n;k++){
					if(k-j+1>=l&&k-j+1<=r)maxx=max(maxx,query(1,1,n,j,k));
//					cout<<query(1,1,n,j,k)<<endl;
				}
			}
//			cout<<maxx<<endl;
			ans^=(unsigned long long)i*maxx;
		}
		cout<<ans<<endl;

	}





	return 0;
}
/*
4
2 4 -5 1
3
1 2
3 4
1 4

*/
C++
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
using ll=unsigned long long;
template<class...Arg>
void println(Arg...arg){
	int _[]={(cout<<arg<<' ',0)...};
	cout<<'\n';
}

int main(){
	cout<<"+++++++++rp++++++++";
	return 0;
}
C++
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
const int N=1e5+8;
int n;
long long m,ans=0;
struct node{
	long long x,y,z;
} a[N];
bool cmp(node gp,node gq){return gp.x<gq.x;}
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >>n>>m;
	for (int i=1;i<=n;++i){
		cin >>a[i].x>>a[i].y;
		a[i].z=a[i].x+a[i].y;
	}
	long long minn=1e18;
	for (int i=1;i<=n;++i){
		minn=min(minn,a[i].z);
	}
	ans=m/minn*2;
	m%=minn;
	sort(a+1,a+1+n,cmp);
	int rp=1,cnt=0;
	while (m>=a[rp].x&&rp<=n){
		m-=a[rp].x;
		++cnt;
		rp++;
	}
	for (;ans>0;){
		int op=0;
		m+=minn;
		while (m>=a[rp].x&&rp<=n){
			m-=a[rp].x;
			++op;
			rp++;
		}
		if (op<2) break;
		cnt+=op;
		ans-=2;
	}
	cout <<ans+cnt;
	return 0;
}
43. GD-0699
C++
//code by ZXZMC
//hacked by ans6 qwq
//it spend me 2.5h!!!
//freopen("candy.in","r",stdin);
//freopen("candy.out","w",stdout);
//slove()
//do not:
//x1,y1,x0,y0
//freeopen()
44. GD-0873
C++
#include<bits/stdc++.h>
using namespace std;
int honkai_starrail,UID_152604873;
int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
//	freopen("query.in","r",stdin);
//	freopen("query.out","w",stdout);
/*
#include<bits\stdc++.h>
	freopen("query.in",r,stdin);
	freopen("query.out",w,stdout);
*/
	cin>>honkai_starrail;
	for(int i=1;i<=honkai_starrail;i++)cin>>UID_152604873;
	cin>>honkai_starrail;
	while(honkai_starrail--)cout<<152604873;
	return 0;
}
45. GD-0789
C++
//mei man fen, jiu zhe yang ba, xi wang you jiu shi
原文
存档评论4 条抓取于