当前位置:网站首页>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;
}
边栏推荐
- 32GB Jetson Orin SOM 不能刷机问题排查
- 期末复习DAY8
- 获取并监控远程服务器日志
- SimpleITK学习笔记
- Brief introduction of realsense d435i imaging principle
- BIO、NIO、AIO区别
- Yolov5 input (II) | CSDN creative punch in
- 6.23 warehouse operation on Thursday
- Communication - how to be a good listener?
- Detailed explanation of the output end (head) of yolov5 | CSDN creation punch in
猜你喜欢

@Autowired 导致空指针报错 解决方式

Simpleitk learning notes

Webrtc protocol introduction -- an article to understand ice, stun, NAT, turn

Gan network thought

【一起上水硕系列】Day 10

redis 无法远程连接问题。

"C and pointer" - Chapter 13 advanced pointer int * (* (* (*f) () [6]) ()

穀歌 | 蛋白序列的深度嵌入和比對

Hotel public broadcasting background music - Design of hotel IP network broadcasting system based on Internet +

Principles of BTC cryptography
随机推荐
SimpleITK学习笔记
Redis 入门和数据类型讲解
Altaro VM backup getting started
mysql启动报错:The server quit without updating PID file几种解决办法
【一起上水硕系列】Day 10
Can altaro back up Microsoft teams?
(perfect solution) how to set the position of Matplotlib legend freely
Robot capture experiment demonstration video
Altaro set grandfather parent child (GFS) archiving
Hotel public broadcasting background music - Design of hotel IP network broadcasting system based on Internet +
Introduction to rust Foundation (basic type)
Source insight License Activation
ES 2022 正式发布!有哪些新特性?
牛客网 JS 分隔符
Common interview questions of microservice
Introduction to webrtc protocol -- an article to understand dtls, SRTP, srtcp
期末复习(DAY7)
Disassembly and installation of Lenovo r7000 graphics card
"C and pointer" - Chapter 13 function of function pointer 1 - callback function 1
Redis使用Lua脚本简介