当前位置:网站首页>Tryout title code
Tryout title code
2022-06-28 06:23:00 【e.. Gravity】
List of articles
A topic . Sum up
Enter an integer matrix , Calculate the sum of the elements at the edge of the matrix . The elements of the edge of the matrix , The elements of the first and last rows and the elements of the first and last Columns . The first row of the input format is the number of rows of the matrix m And number of columns n(m<100,n<100), The two are separated by a space .
Input:
3 3
3 4 1
3 7 1
2 0 1
Output:
15
#include<iostream>
using namespace std;
int main()
{
int m,n;
cin>>m>>n;
int arr[100][100]={
0};
int sum=0;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>arr[i][j];
if(i==0||i==m-1||j==0||j==n-1){
sum+=arr[i][j];
}
}
}
cout<<sum<<endl;
return 0;
}
B topic . Play and play

#include<iostream>
using namespace std;
int main()
{
double h;
double sum=0,a;
cin>>h;
a=h/2.0;
sum=h;
for(int i=1;i<10;i++)
{
sum+=2.0*a;
a/=2.0;
}
cout<<sum<<endl;
cout<<a<<endl;
return 0;
}
C topic . Fractional decimal

#include<iostream>
using namespace std;
int main()
{
int a, b, n;
cin >> a >> b >> n;
for (int i = 0; i < n; i++) {
a = a % b;
a *= 10;
}
cout << a / b << endl;
return 0;
}
The array I used in the competition , I feel that everything has been considered , Still can't pass ,
The class leader solved it in a few lines
D topic . Palindrome

#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char arr[110];
cin>>arr;
bool flag=true;
int len=strlen(arr);
for(int i=0;i<len/2;i++)
{
if(arr[i]!=arr[len-1-i]){
flag=false;
}
}
if(flag){
cout<<"yes"<<endl;
}
else{
cout<<"no"<<endl;
}
return 0;
}
E topic . Children out of line

#include<iostream>
using namespace std;
char arr[65][20];
int main()
{
int n, w, s;
char ch;;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
cin >> w >> ch >> s;
int count = 0;
w = w - 2;
while (count < n) {
for (int i = 0; i < s; i++) {
w = (++w) % n;
if (arr[w][18] == '1') {
i--;
}
}
cout << arr[w] << endl;
arr[w][18] = '1';
count++;
}
return 0;
}
F topic . Closed interval

#include<iostream>
#include<cstring>
#include<string>
int arr[10010];
using namespace std;
int main()
{
int n;
cin>>n;
int min_1=99999,max_1=-12;
for(int i=0;i<n;i++){
int a,b;
cin>>a>>b;
if(a<min_1){
min_1=a;
}
if(b>max_1){
max_1=b;
}
for(int j=a;j<=b;j++){
arr[j]=1;
}
}
bool flag=true;
for(int i=min_1;i<=max_1;i++)
{
if(arr[i]==0){
flag=false;
}
}
if(flag){
cout<<min_1<<" "<<max_1<<endl;
}
else{
cout<<"no"<<endl;
}
return 0;
}
I topic . Award for excellence

#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int brr[N];
int n, m;
bool fun(int n)
{
int l = 0;
int r = m - 1;
while (l <= r) {
int mid = (l + r) >> 1;
if (brr[mid] < n) {
l = mid + 1;
}
else if (brr[mid] > n) {
r = mid - 1;
}
else {
return 1;
}
}
return 0;
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
for (int i = 0; i < m; i++) {
cin >> brr[i];
}
sort(brr, brr + m);
for (int i = 0; i < n; i++) {
if (fun(arr[i])) {
cout << arr[i] << " ";
}
}
return 0;
}
边栏推荐
- 4. use MySQL shell to install and deploy Mgr clusters | explain Mgr in simple terms
- Freeswitch使用originate转dialplan
- 自定义 cube-ui 弹出框dialog支持多个且多种类型的input框
- socke.io长连接实现推送、版本控制、实时活跃用户量统计
- CAD secondary development +nettopologysuite+pgis reference multi version DLL
- OpenSCAP 简介
- YYGH-BUG-03
- Use the SQL SELECT count distinct query statement to count the total number of unique values of a field in the database
- EasyUI reset multi condition query
- Uni app wechat applet sharing function
猜你喜欢

链表(一)——移除链表元素

ROS rviz_satellite功能包可视化GNSS轨迹,卫星地图的使用

FPGA - 7系列 FPGA SelectIO -07- 高级逻辑资源之ISERDESE2

Install and manage multiple versions of PHP under mac

Yygh-7-user management

Openharmony gnawing paper growth plan -- json-rpc

death_ satan/hyperf-validate

JQ picture amplifier

FPGA - 7系列 FPGA SelectIO -08- 高级逻辑资源之OSERDESE2

Introduction to browser tools: think sky browser, team work browser
随机推荐
Idea generates entity classes from database tables
Caused by: com. fasterxml. jackson. databind. Exc.invalidformatexception: exception resolution
What is the e-commerce conversion rate so abstract?
AutoCAD C# 多段线自相交检测
AttributeError: 'callable_iterator' object has no attribute 'next'
Integer promotion and size side byte order
手把手教你用Ucos
慢内容广告:品牌增长的长线主义
借助nz-pagination中的let-total解析ng-template
YYGH-BUG-03
链表(一)——移除链表元素
Idea automatically adds comments when creating classes
助力涨点 | YOLOv5结合Alpha-IoU
Oracle fundamentals summary
Drop down list processing in Web Automation
4. use MySQL shell to install and deploy Mgr clusters | explain Mgr in simple terms
重载,重写的区别,抽象类,接口的区别
链表(三)——反转链表
API learning of OpenGL (2006) glclientactivetexture
职场IT老鸟的几点小习惯