首页 > 其他分享 >牛客小白月赛63 ABCD

牛客小白月赛63 ABCD

时间:2023-04-06 20:33:16浏览次数:45  
标签:ABCD typedef const int LL cin long 牛客 63

https://ac.nowcoder.com/acm/contest/49030

这套题目质量挺好的,E过了200+,状态不佳,改天补补

A-子序列的权值最小值

输入 
6
1 1 4 5 1 4
输出 
0
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=2e7+10,M=2023;
const LL mod=1e9+7;
const double PI=3.1415926535;
#define endl '\n'
LL a[N],b[N];  
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
    	LL n;
    	cin>>n;
    	LL sum=0;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>a[i];
    		if(i==1) sum=a[i];
    		else sum&=a[i];
		}
		cout<<sum<<endl;
    }
    return 0;
}

B-魔导师晨拥

输入 
5 6
1 2 3 4 5
输出 
36
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=2e7+10,M=2023;
const LL mod=1e9+7;
const double PI=3.1415926535;
#define endl '\n'
LL a[N],b[N];  
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
    	LL n,m;
    	cin>>n>>m;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>a[i];
		}
		LL beg=2;
		LL ans=0;
    	       for(int i=1;i<=m;i++)
    	       {
    		for(int j=1;j<=n;j++)
    		{
    			a[j]-=beg;
    			if(a[j]==0) beg++;
			}
			ans+=beg;
		}
		cout<<ans<<endl;
    }
    return 0;
}

C-GCPC总决赛

输入 
2
0 2
1 3
输出 
0 1 1

数据范围小,直接暴力即可

方法一

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=1e6+10,M=5005;
const LL mod=100000007;
const double PI=3.1415926535;
#define endl '\n'
LL a[N],b[N];
LL num[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
    	LL n;
    	cin>>n;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>a[i];
    		num[i]=i;
		}
		for(int i=1;i<=n;i++)
		{
			cin>>b[i];
		}
		LL sum1=0,sum2=0,sum3=0;
		do
		{
			LL x=0,y=0,z=0;
			for(int i=1;i<=n;i++)
			{
				int aa=a[num[i]],bb=b[i];
				if(aa>bb) x++;
				else if(aa<bb) y++;
				else z++;
			}
			if(x>y) sum1++;
			else if(x<y) sum2++;
			else sum3++;
		}
		while(next_permutation(num+1,num+1+n));
		cout<<sum1<<" "<<sum2<<" "<<sum3<<endl;
	}
    return 0;
}

方法二

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=1e6+10,M=5005;
const LL mod=100000007;
const double PI=3.1415926535;
#define endl '\n'
LL n,sum1=0,sum2=0,sum3=0;
LL a[N],b[N];
bool st[N];
vector<LL> v;
void dfs(int idx)
{
	if(idx>n)
	{
		LL x=0,y=0,z=0;
		for(int i=0;i<v.size();i++)
		{
			if(v[i]>b[i+1]) x++;
			else if(v[i]<b[i+1]) y++;
			else z++;
		}
		if(x>y) sum1++;
		else if(x<y) sum2++;
		else sum3++;
		return ;
	}
	for(int i=1;i<=n;i++)
	{
		if(st[i]==0)
		{
			st[i]=1;
			v.push_back(a[i]);
			dfs(idx+1);
			v.pop_back();
			st[i]=0;
		}
	}
}
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
    	cin>>n;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>a[i];
		}
		for(int i=1;i<=n;i++)
		{
			cin>>b[i];
		}
		dfs(1);
		cout<<sum1<<" "<<sum2<<" "<<sum3<<endl;
	}
    return 0;
}

D-Ginger的大花环

输入 
5 4
1 2 3 4
输出 
7 

输入 
3 1
1
输出 
Ginger666
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=1e6+10,M=5005;
const LL mod=100000007;
const double PI=3.1415926535;
#define endl '\n'
LL a[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
    	LL n,k;
    	cin>>n>>k;
    	for(int i=1;i<=k;i++)
    	{
    		cin>>a[i];
		}
		if(k<=1) cout<<"Ginger666"<<endl;
		else
		{
			sort(a+1,a+1+k);
			if(n%3==0) cout<<(n/3)*(2*a[1]+a[2]);
			else if(n%3==1) cout<<(n/3)*(2*a[1]+a[2])+a[2];
			else if(n%3==2) cout<<(n/3)*(2*a[1]+a[2])+a[1]+a[2];
		}
	}
    return 0;
}

标签:ABCD,typedef,const,int,LL,cin,long,牛客,63
From: https://www.cnblogs.com/Vivian-0918/p/17294070.html

相关文章

  • ASEMI代理AD633JRZ原装ADI车规级AD633JRZ
    编辑:llASEMI代理AD633JRZ原装ADI车规级AD633JRZ型号:AD633JRZ品牌:ADI/亚德诺封装:SOIC-8批号:2023+安装类型:表面贴装型引脚数量:8类型:车规级芯片AD633JRZ特性特征四象限乘法低成本、8引脚SOIC和PDIP封装完整无需外部组件激光修整的精度和稳定性全刻度2%以内的总误差差分高阻抗X和Y输入......
  • ASEMI代理AD633JRZ原装ADI车规级AD633JRZ
    编辑:llASEMI代理AD633JRZ原装ADI车规级AD633JRZ型号:AD633JRZ品牌:ADI/亚德诺封装:SOIC-8批号:2023+安装类型:表面贴装型引脚数量:8类型:车规级芯片AD633JRZ特性特征四象限乘法低成本、8引脚SOIC和PDIP封装完整无需外部组件激光修整的精度和稳定性全刻度2%以内的总误差......
  • Codeforces Round 863 (Div. 3)
    CodeforcesRound863(Div.3)链接CodeforcesRound863(Div.3)A题遍历这个字符串,如果要插入的数第一次小于当前的数,就将数插入到这里,如果到最后都没有插入数,插入到最后#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<vec......
  • Codeforces Round 863 (Div. 3) E题
    题目地址题意:定义数组a包含所有不含数字4的正整数,给出一个n,要求求出数组a中第n个数Solution数位dp+二分,求出[1,mid]中不含数字4的正整数个数,不过因为有可能mid包含4,但是由于贡献是一样的,可以直接把4都变成3,最后处理一下即可intdp[20];inta[20];voidinit(){ dp[0]=1; f......
  • 牛客小白月赛61 ABCE*
    https://ac.nowcoder.com/acm/contest/46597A-超市里扫货#include<bits/stdc++.h>usingnamespacestd;typedeflonglongLL;typedefpair<LL,LL>PII;constLLMAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;constLLN=2e6+10,M=3023;constLLmod=100000007;const......
  • Codeforces Round 863 (Div. 3)
    A.InsertDigit放在第一个比他小的数前面#include<bits/stdc++.h>usingnamespacestd;voidsolve(){intn,d;cin>>n>>d;strings;cin>>s;for(chari:s){if(d>i-'0')cout<<d,d......
  • Codeforces Round 640 (Div. 4) ABCDEFG
    https://codeforces.com/contest/1352不知道怎么的复制过来的代码容易歪,观看效果可能不大好。这场古早div4,大题极其友好,除了E卡空间卡到我爆炸,别的都体验感极好。A.SumofRoundNumbers#include<bits/stdc++.h>usingnamespacestd;typedeflonglongLL;typedefpai......
  • Codeforces Round 863 (Div. 3) A-C 赛后思路复盘
    A(思维)思路:观察样例可知数越大放在前面越优。遍历字符串,判断当前位置的数字和要插入的数字的关系,如果要插入的数大于当前数,那么就插入到当前数的前面。string里有一个insert函数,可以把指定字符串插入到指定下标之前。在原串下标为pos的字符前插入字符串strbasic_string&insert......
  • cf-div.3-863d
    题目链接:https://codeforces.com/contest/1811/problem/D思维题,昨天被E题搞太久了,这题认真想的话应该可以出的。思路:不断循环,判断x和y是否在合法区间内。代码:#include<bits/stdc++.h>usingnamespacestd;constintN=2e5+10;longlongfib[70];voidsolve(){int......
  • 牛客,第二十届北京师范大学程序设计竞赛,签到题7题
    序题号标题已通过代码通过率团队的状态A小凯的疑惑点击查看434/745通过B幻象踩花点击查看121/434通过C跳刀抓人点击查看26/178通过D真正的卡尔点击查看115/714通过E刷新的艺术点击查看31/479通过F最后的战役点击查看1/39未通过G随机数生成器点击......