当前位置:网站首页>PAT1008
PAT1008
2022-08-09 11:09:00 【AlanLiu6】
最近英语水平突飞猛进
https://pintia.cn/problem-sets/994805342720868352/problems/994805511923286016
#include<cstdio>
int num[10005];
int flag[101];
int N;
int main()
{
scanf("%d",&N);
num[0] = 0;
flag[0] = 1;
int j =1;
for(int i = 0;i < N;i++)
{
int t;
scanf("%d",&t);
num[j] = t;
j++;
flag[t] = 1;
}
int sum = 0;
for(int i = 0;i < j-1;i++)
{
int t = num[i+1] - num[i];
if(t > 0) sum += 6*t+5;
else if(t < 0) sum += 4*(-t)+5;
else sum += 5;
}
printf("%d\n",sum);
return 0;
}
边栏推荐
猜你喜欢
随机推荐
Number theory knowledge
去除蜂窝状的噪声(matlab实现)
PAT1010
Oracle数据库的两种进入方式
获取指定年度所有周的工具类
fork创建多个子进程
ICML 2022 | Out-of-Distribution Detection with Deep Nearest Neighbors
Beauty Values
fork creates multiple child processes
mysql参数学习----max_allowed_packet
Qt获取EXE可执行文件的上一级目录下的文件
STM32启动方式及BootLoader
PAT1003
x86异常处理与中断机制(3)中断处理过程
Error: Cannot find module ‘./application‘
CentOS6.5 32bit安装Oracle、ArcSde、Apache等配置说明
People | How did I grow quickly from programmer to architect?
二进制加法
OpenSSF's open source software risk assessment tool: Scorecards
leetcode-搜索旋转排序数组-33