当前位置:网站首页>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;
}
边栏推荐
- Skip table: principle introduction, advantages and disadvantages of skiplist
- (subplots usage) Matplotlib how to draw multiple subgraphs (axis field)
- Obtenir et surveiller les journaux du serveur distant
- 获取并监控远程服务器日志
- Webrtc native M96 version opening trip -- a reading code download and compilation (Ninja GN depot_tools)
- Covering Safari and edge, almost all mainstream browsers have realized webgl 2.0 support
- [basic grammar] Snake game written in C language
- Redis 入門和數據類型講解
- Go practice -- gorilla/rpc (gorilla/rpc/json) used by gorilla web Toolkit
- College campus IP network broadcasting - manufacturer's design guide for college campus IP broadcasting scheme based on campus LAN
猜你喜欢

Common interview questions of microservice

Why is go language particularly popular in China

Progressive multi grasp detection using grasp path for rgbd images

Map的扩容机制

【实战项目】自主web服务器

微服务常见面试题

大学校园IP网络广播-厂家基于校园局域网的大学校园IP广播方案设计指南

DEX net 2.0 for crawl detection

小学校园IP网络广播-基于校园局域网的小学IP数字广播系统设计

Altaro o365 total backup subscription plan
随机推荐
Common interview questions of microservice
ES 2022 正式发布!有哪些新特性?
Transferring images using flask
Congratulations to musk and NADELLA on their election as academicians of the American Academy of engineering, and Zhang Hongjiang and Fang daining on their election as foreign academicians
Redis expiration elimination mechanism
Hotel public broadcasting background music - Design of hotel IP network broadcasting system based on Internet +
Yolov5 input (II) | CSDN creative punch in
redis 遇到 NOAUTH Authentication required
Simpleitk learning notes
期末复习(DAY6)
Detailed explanation of the output end (head) of yolov5 | CSDN creation punch in
Learn libcef together -- set cookies for your browser
Can altaro back up Microsoft teams?
Apache+PHP+MySQL环境搭建超详细!!!
【实战项目】自主web服务器
Best practices for setting up altaro VM backups
Explanation of variables, code blocks, constructors, static variables and initialization execution sequence of static code blocks of Ali interview questions
NG Textarea-auto-resize
今天很多 CTO 都是被幹掉的,因為他沒有成就業務
2022.6.30DAY591