当前位置:网站首页>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;
}
边栏推荐
- The IntelliJ platform completely disables the log4j component
- NG Textarea-auto-resize
- Training method of grasping angle in grasping detection
- Beaucoup de CTO ont été tués aujourd'hui parce qu'il n'a pas fait d'affaires
- Go practice -- factory mode of design patterns in golang (simple factory, factory method, abstract factory)
- 期末复习(Day5)
- Get and monitor remote server logs
- Yolov5 model construction source code details | CSDN creation punch in
- How to use source insight
- Altaro virtual machine replication failed: "unsupported file type vmgs"
猜你喜欢

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

redis 无法远程连接问题。

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

Altaro set grandfather parent child (GFS) archiving

Webrtc M96 release notes (SDP abolishes Plan B and supports opus red redundant coding)

XML Configuration File

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

Pan details of deep learning

Detailed explanation of yolov5 training own data set

College campus IP network broadcasting - manufacturer's design guide for college campus IP broadcasting scheme based on campus LAN
随机推荐
Altaro VM backup getting started
EMD distance - example of use
[basic grammar] Snake game written in C language
Making coco datasets
The request database reported an error: "could not extract resultset; SQL [n/a]; needed exception is org.hibernate.exception.sqlgram"
今天很多 CTO 都是被干掉的,因为他没有成就业务
Altaro set grandfather parent child (GFS) archiving
Robot capture experiment demonstration video
Webrtc protocol introduction -- an article to understand ice, stun, NAT, turn
Beaucoup de CTO ont été tués aujourd'hui parce qu'il n'a pas fait d'affaires
mapbox尝鲜值之云图动画
Introduction to webrtc protocol -- an article to understand dtls, SRTP, srtcp
Map的扩容机制
Can altaro back up Microsoft teams?
Go practice -- generate and read QR codes in golang (skip2 / go QRcode and boombuilder / barcode)
请求数据库报错:“could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGram
酒店公共广播背景音乐-基于互联网+的酒店IP网络广播系统设计
redis 遇到 NOAUTH Authentication required
Technical analysis of qianyuantong multi card aggregation router
Yolov5 network structure + code + application details | CSDN creation punch in