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

ck 2023-03-11 10:45:16

 

 

分数 - 蓝桥云课 (lanqiao.cn)

#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#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 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 = 1e5+ 10,M = 1e5 + 10,INF = 0x3f3f3f3f ;
const int mod = 1e9;
const double eps = 1e-8;


int n;


inline void solve()
{
	LL a =0,b=1;
	
	for(int i=0;i < 20 ; i++  )
	{
		a  += 1 << i; b = 1<<i ;
	}
	printf("%d/%d",a,b);			
}


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

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


    return 0;
}

回文日期 - 蓝桥云课 (lanqiao.cn)

#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#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 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 = 1e5+ 10,M = 1e5 + 10,INF = 0x3f3f3f3f ;
const int mod = 1e9;
const double eps = 1e-8;


int n;

int d[]={0,31,28,31,30,31,30,31,31,30,31,30,31};


bool check(int a)
{
	string s = to_string(a);
	
	for(int i=0,j=s.size() - 1; i< j ; i ++ , j-- )
	if(s[i] != s[j]) return 0;
	return 1;
}

bool check1(int x)
{
	int t = (x % 10000) /100;
	int day = x % 100 ;
	if(day > d[t] ) return 0; 
	
	if(day <=0 || day > 31 ) return 0;
	if(t<= 0 || t > 12 ) return 0;
	return 1;
}


inline void solve()
{
	cin >> n ;n ++ ;
	int u = n ; 
	
	fu(i,1000,9999)
	{
		int t = i ,now = i;while(t) now = now * 10 + t % 10 ,t /=10;
		if(check(now) && check1(now) && now >= n )
		{
			cout << now << endl;break;
		}
	}
	
	
	fu(a,1,9)
	fu(b,0,9)
	if(a != b)
	{
		int t = a * 1e7 + b * 1e6 + a * 1e5 + b* 1e4 + b * 1e3 + a * 1e2 + b * 10 + a;
		if(check(t) && t >= n && check1(t))
		{
			cout<<t << endl;return;
		}
	}

			
}


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

    int t=1;
//    cin>>t;
    int now = 1;
    while(t -- )
    {
//      cout<<"Case "; 
//      cout<<"Case #"; 
//      cout<< now ++ <<": ";
        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 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 = 2e3+ 10,M = 1e5 + 10,INF = 0x3f3f3f3f ;
const int mod = 1e9;
const double eps = 1e-8;

int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int n,m;
vector<PII> door[N][N];
bool st[N][N],is_door[N][N];
int d[N][N];

void bfs()
{
	ms(d,0x3f);
	d[n][n] = 0;
	queue<PII> q;
	q.push({n,n});
	
	while(q.size())
	{
		auto t = q.front();q.pop();
		
		fu(i,0,3)
		{
			int a = t.x + dx[i],b= t.y + dy[i];
			if(a < 1 || a > n || b < 1 || b > n ) continue;
			
			if(is_door[t.x][t.y])
			{
				for(auto u:door[t.x][t.y])
				{
					if(d[u.x][u.y] > d[t.x][t.y] + 1 )
					{
						d[u.x][u.y] = d[t.x][t.y] + 1;
						q.push({u.x,u.y});
					}
				}
				
			}
			
			
			if(d[a][b] > d[t.x][t.y] + 1 )
			{
				d[a][b] = d[t.x][t.y] +  1;
				q.push({a,b});
			}
			
			
			
		}
		
		
	}
	
	
	
	
}


inline void solve()
{
	cin >> n>> m;	
	fu(i,0,m-1)
	{
		int a,b,c,d;cin >> a>> b >> c >> d;
		door[a][b].push_back({c,d});
		door[c][d].push_back({a,b});
		is_door[a][b] = is_door[c][d] = 1;
	}
	
	bfs();
	int sum =0 ;
	fu(i,1,n)
	fu(j,1,n)
	{
		sum += d[i][j];
	}
			
	printf("%.2lf",1.0 * sum / (  n * n ));		
}


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

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


    return 0;
}

 

 

 

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

51,683

社区成员

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

 刷题!

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