第十四届蓝桥杯三月真题刷题训练——第 10 天(3.13)

ck 2023-03-12 21:43:21

裁纸刀 - 蓝桥云课 (lanqiao.cn)

#include <iostream>
using namespace std;
int main()
{
  // 请在此输入您的代码
  cout << 440 - 1 + 4  <<endl;
  return 0;
}

刷题统计 - 蓝桥云课 (lanqiao.cn)

#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define x first
#define y second
#define fu(i,a,b) for(int i=a;i<=b;i ++ )
#define fd(i,a,b) for(int i=a;i>=b;i -- )
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

typedef long long LL;
typedef vector<vector<LL>> VVL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<double,int> PDI;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
typedef __int128 i128;
typedef unsigned long long ULL;
const int N = 500+ 10,M = N * 4,INF = 0x3f3f3f3f ;
const int mod = 1e9; 
const double eps = 1e-8;




inline void solve()
{
	LL a,b,n;
	cin >> a >> b >> n ;
	
	LL cnt = 0,res =0,sum = a * 5 + b* 2 ;
	cnt += n/sum  * 7 ;
	n %= sum; 
	
	while(res < n )
	{
		if(cnt % 7 < 5 ) res += a;
		else res +=b;
		cnt ++ ;
	}
	cout << cnt<< endl;
	
}


signed main()
{
//  freopen("1.txt","w",stdout);
 	ios

    int t=1;
//    cin>>t;
    int now = 1;
    while(t -- )
    {
//      cout<<"Case "; 
//      cout<<"Scenario #"; 
//      cout<< now ++ <<": ";
//      cout<< now ++ <<": \n";
        solve();
    }


    return 0;
}

修剪灌木 - 蓝桥云课 (lanqiao.cn)

#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define x first
#define y second
#define fu(i,a,b) for(int i=a;i<=b;i ++ )
#define fd(i,a,b) for(int i=a;i>=b;i -- )
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

typedef long long LL;
typedef vector<vector<LL>> VVL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<double,int> PDI;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
typedef __int128 i128;
typedef unsigned long long ULL;
const int N = 500+ 10,M = N * 4,INF = 0x3f3f3f3f ;
const int mod = 1e9; 
const double eps = 1e-8;




inline void solve()
{
	int n;
	cin >> n;
	fu(i,1,n)
	cout << max(i-1,n-i) * 2  << endl;
	
		
}


signed main()
{
//  freopen("1.txt","w",stdout);
 	ios

    int t=1;
//    cin>>t;
    int now = 1;
    while(t -- )
    {
//      cout<<"Case "; 
//      cout<<"Scenario #"; 
//      cout<< now ++ <<": ";
//      cout<< now ++ <<": \n";
        solve();
    }


    return 0;
}

k倍区间 - 蓝桥云课 (lanqiao.cn)

#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define x first
#define y second
#define fu(i,a,b) for(int i=a;i<=b;i ++ )
#define fd(i,a,b) for(int i=a;i>=b;i -- )
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

typedef long long LL;
typedef vector<vector<LL>> VVL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<double,int> PDI;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
typedef __int128 i128;
typedef unsigned long long ULL;
const int N = 500+ 10,M = N * 4,INF = 0x3f3f3f3f ;
const int mod = 1e9; 
const double eps = 1e-8;




inline void solve()
{
	int n,m;
	cin >> n >> m ;
	vector<int> cnt(m + 10 );
	vector<LL> s(n+10);
	fu(i,1,n)cin >> s[i],s[i] += s[i-1];
	LL res =0 ;
	cnt[0] ++ ;
	fu(i,1,n)res += cnt[s[i] % m ] ++ ;
	
		
	cout << res <<endl;	
}


signed main()
{
//  freopen("1.txt","w",stdout);
 	ios

    int t=1;
//    cin>>t;
    int now = 1;
    while(t -- )
    {
//      cout<<"Case "; 
//      cout<<"Scenario #"; 
//      cout<< now ++ <<": ";
//      cout<< now ++ <<": \n";
        solve();
    }


    return 0;
}

k倍区间 - 蓝桥云课 (lanqiao.cn)

#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define x first
#define y second
#define fu(i,a,b) for(int i=a;i<=b;i ++ )
#define fd(i,a,b) for(int i=a;i>=b;i -- )
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

typedef long long LL;
typedef vector<vector<LL>> VVL;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<double,int> PDI;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
typedef __int128 i128;
typedef unsigned long long ULL;
const int N = 1e6+ 10,M = N * 4,INF = 0x3f3f3f3f ;
const int mod = 1e9; 
const double eps = 1e-8;

int n,m;
unordered_map<int,vector<int>> tr;

int find(VL &t,LL x)
{
	return lower_bound(t.begin(),t.end(),x) - t.begin() +  1; 
}
int lowbit(int x)
{
	return x  & -x ;
}
void add(VI & t,int x,LL c)
{
	for(int i=x;i<t.size();i+=lowbit(i)) t[i] += c;
}

LL sum(VI &t,int x)
{
	LL res =0 ;
	for(int i=x;i;i-=lowbit(i))	res += t[i];
	return res;
}

inline void solve()
{
	cin >> n >> m ;
	unordered_map<int,vector<LL>> cnt;

	vector<LL> s(n+10);
	LL res =0 ;
	fu(i,1,n)
	{
		cin >> s[i],s[i] += s[i-1];
		int t = (s[i] % m + m ) % m;
		cnt[t].push_back(s[i]);
	}
	
	for(auto &t: cnt )
	{
		VL &ve =t.y ;
		sort(ve.begin(),ve.end());
		ve.erase(unique(ve.begin(),ve.end()),ve.end());
		tr[t.x] = VI(ve.size()+1,0);
	}
	
	
	fu(i,1,n)
	{
		int t =(s[i] % m + m ) % m;
		int x = find(cnt[t],s[i]);
		
		if(!t && s[i] >= 0 ) res ++ ;
		res += sum(tr[t],x);
		add(tr[t],x,1);
		
		
	}
		
	
		cout << res <<endl;
		
}


signed main()
{
//  freopen("1.txt","w",stdout);
 	ios

    int t=1;
//    cin>>t;
    int now = 1;
    while(t -- )
    {
//      cout<<"Case "; 
//      cout<<"Scenario #"; 
//      cout<< now ++ <<": ";
//      cout<< now ++ <<": \n";
        solve();
    }


    return 0;
}

 

...全文
24 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,592

社区成员

发帖
与我相关
我的任务
社区描述
和众多高校算法内卷分子,一起学习和交流算法那。浓郁的算法交流氛围,拒绝躺平,有效内卷。加入我们,私信我拉你入核心内卷群。
算法数据结构leetcode 个人社区
社区管理员
  • 执 梗
  • Dream-Y.ocean
  • ღCauchyོꦿ࿐
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

 刷题!

试试用AI创作助手写篇文章吧