当前位置:网站首页>AtCoder Beginner Contest 258(A-D)
AtCoder Beginner Contest 258(A-D)
2022-07-03 05:35:00 【. Ashy.】
A - When?
The main points of : Format output time
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+7;
int n;
int main()
{
cin>>n;
int h=n/60+21;
int m=n%60;
printf("%02d:%02d",h,m);
}
B Number Box
Be careful :
Note that the search is in eight straight directions , Instead of searching eight directions every time , Because no matter how to search the string length, it is certain , So we only start with the largest number at the beginning
Pay attention to the questions
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+7;
int n;
char a[21][21];
int max1;
string ans="";
int dir[8][2]={
0,1,0,-1,1,0,-1,0,1,1,1,-1,-1,1,-1,-1};
void serch(int x,int y)
{
string s1="";
int xx=x;
for(int i=1;i<=n;i++)
{
s1+=a[xx][y];
xx++;
if(xx>n) xx=1;
}// Right
ans=max(ans,s1);
s1="";
xx=x;
for(int i=1;i<=n;i++)
{
s1+=a[xx][y];
xx--;
if(xx<1) xx=n;
}// Left
ans=max(ans,s1);
s1="";
int yy=y;
for(int i=1;i<=n;i++)
{
s1+=a[x][yy];
yy++;
if(yy>n) yy=1;
}// On
ans=max(ans,s1);
s1="";yy=y;
for(int i=1;i<=n;i++)
{
s1+=a[x][yy];
yy--;
if(yy<1) yy=n;
}// Next
ans=max(ans,s1);
s1="";xx=x,yy=y;
for(int i=1;i<=n;i++)
{
s1+=a[xx][yy];
xx--;
yy--;
if(xx<1) xx=n;
if(yy<1) yy=n;
}// Top left
ans=max(ans,s1);
s1="";xx=x,yy=y;
for(int i=1;i<=n;i++)
{
s1+=a[xx][yy];
xx++;
yy++;
if(xx>n) xx=1;
if(yy>n) yy=1;
}// The lower right
ans=max(ans,s1);
s1="";xx=x,yy=y;
for(int i=1;i<=n;i++)
{
s1+=a[xx][yy];
xx++;
yy--;
if(xx>n) xx=1;
if(yy<1) yy=n;
}// The upper right
ans=max(ans,s1);
s1="";xx=x,yy=y;
for(int i=1;i<=n;i++)
{
s1+=a[xx][yy];
xx--;
yy++;
if(xx<1) xx=n;
if(yy>n) yy=1;
}// The lower left
ans=max(ans,s1);
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++) ans+='1';
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cin>>a[i][j];
max1=max(max1,a[i][j]-'0');
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(a[i][j]-'0'==max1)
{
serch(i,j);
}
}
}
cout<<ans;
}
C Rotation
Ideas :
We use it k Represents the number of shift operations , When k == n Time is equivalent to no movement Then the number of effective moves is k%n , Then the original header is equivalent to being moved to n-k The location of , Requirement No b Letters , That's it n-k+b The letter of position , Of course , This number should also be correct n Remainder , If you exceed n
Represents that this number has been moved to the front , So take the rest .
Be sure to note that the remainder equals 0 Does the situation of have an impact on the problem !!!!
Try more groups of examples !!!
Pay attention long long
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+7;
ll n,m;
string s;
ll a,b,k,sum;
int main()
{
cin>>n>>m;
cin>>s;
for(int i=1;i<=m;i++)
{
scanf("%lld %lld",&a,&b);
if(a==1)
{
k+=b;
k=k%n;
}
else
{
int kk=((n-k)+b)%n;if(kk==0) kk=n;
cout<<s[kk-1]<<endl;
}
}
}
D:Trophy
The question :
n Stages , From the first stage , Each new stage will cost a+b , Staying in the unlocked phase only costs b , ask Handle X What is the minimum cost of the second stage
Ideas :
We need to find a smaller one b, Make most of The treatment of is in b On , Not in a+b On , Make the cost smaller , So the idea of this question is to unlock each stage , Then process all the remaining processing times in this stage, that is, spend this b , At every stage b Try it all once , Minimum value .
Note that the data is relatively large , open ull
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int N = 1e5+7;
ll min1=1e19+10;
ll n,t;
ll a,b;
ll sum;
int main()
{
cin>>n>>t;
for(int i=1;i<=n;i++)
{
scanf("%llu %llu",&a,&b);
sum+=(a+b);
min1=min(min1,sum+b*(t-i));
}
cout<<min1;
}
边栏推荐
- Differences among bio, NiO and AIO
- [practical project] autonomous web server
- [basic grammar] Snake game written in C language
- Introduction to webrtc protocol -- an article to understand dtls, SRTP, srtcp
- 3dslam with 16 line lidar and octomap
- Export the altaro event log to a text file
- ansible防火墙firewalld设置
- 牛客网 JS 分隔符
- 期末复习(Day5)
- Pytorch through load_ state_ Dict load weight
猜你喜欢

College campus IP network broadcasting - manufacturer's design guide for college campus IP broadcasting scheme based on campus LAN

Go practice - gorilla / handlers used by gorilla web Toolkit

mapbox尝鲜值之云图动画

Linux登录MySQL出现ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)

Brief introduction of realsense d435i imaging principle

Deep embedding and alignment of Google | protein sequences

Apache+PHP+MySQL环境搭建超详细!!!

乾元通多卡聚合路由器的技术解析

Webrtc native M96 version opening trip -- a reading code download and compilation (Ninja GN depot_tools)

Pan details of deep learning
随机推荐
Go practice -- gorilla/rpc (gorilla/rpc/json) used by gorilla web Toolkit
Redis使用Lua脚本简介
求质数的方法
Common interview questions of microservice
联想R7000显卡的拆卸与安装
(subplots usage) Matplotlib how to draw multiple subgraphs (axis field)
Final review (day3)
Source insight automatic installation and licensing
Covering Safari and edge, almost all mainstream browsers have realized webgl 2.0 support
Final review (Day6)
DEX net 2.0 for crawl detection
Principles of BTC cryptography
期末复习(DAY6)
ES 2022 正式发布!有哪些新特性?
Gan network thought
kubernetes资源对象介绍及常用命令(五)-(ConfigMap)
Introduction to rust Foundation (basic type)
Redis 击穿穿透雪崩
一起上水硕系列】Day 9
Redis Introduction et explication des types de données