当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

What is the e-commerce conversion rate so abstract?

freeswitch设置最大呼叫时长

链表(二)——设计链表

助力涨点 | YOLOv5结合Alpha-IoU

Development trend of mobile advertising: Leveraging stock and fine marketing

socke.io長連接實現推送、版本控制、實時活躍用戶量統計

Uni app wechat applet sharing function

自定义 cube-ui 弹出框dialog支持多个且多种类型的input框

Apple MDM bypass jailfree bypass MDM configuration lock free

High quality domestic stereo codec cjc8988, pin to pin replaces wm8988
随机推荐
freeswitch使用mod_shout模块播放mp3
Teach you how to use UCOS
创建格式化时间,格式化时区的gson对象。json解析时间格式化 ZonedDateTime
移动广告发展动向:撬动存量,精细营销
Alibaba cloud SMS service (Complete Guide), SMS sending function implementation.
AutoCAD C # Polyline Small Sharp angle Detection
CAD二次开发+NetTopologySuite+PGIS 引用多版本DLL问题
Apple MDM bypass jailfree bypass MDM configuration lock free
Caused by: com. fasterxml. jackson. databind. Exc.invalidformatexception: exception resolution
eyebeam高级设置
YYGH-BUG-02
Simple handwritten debounce function
MySQL(二)——基本操作
fpm工具安装
Deep learning 19 loss functions
YYGH-BUG-03
链表(一)——移除链表元素
三极管驱动无刷电机
记JPA使用自定义VO接收 JPQL查询结果
Taobao seo training video course [22 lectures]