PAT甲級1008題(Elevator)
#include <stdio.h> #include <math.h> int main() { int N,i,j; int sum=0; int a[100]; scanf("%d",&N); sum+=5*N; for(i=0; i<N; i++) { scanf("%d",&a[i]); } sum+=6*a[0]; for(j=0; j<N-1; j++) { if(a[j+1]>a[j]) { sum+=6*(a[j+1]-a[j]); } else if(a[j+1]<a[j]) { sum+=4*(a[j]-a[j+1]); } } if(a[N-1]==0){sum-=5;} printf("%d",sum); return 0; }
相關推薦
PAT甲級1008題(Elevator)
#include <stdio.h> #include <math.h> int main() { int N,i,j; int sum=0; int a[100]; scanf("%d",&N); su
1037. Magic Coupon (25)-PAT甲級真題(貪心演算法)
1037. Magic Coupon (25)The magic shop in Mars is offering some magic coupons. Each coupon has an in
1091. Acute Stroke (30)-PAT甲級真題(廣度優先搜尋)
1091. Acute Stroke (30)One important factor to identify acute stroke (急性腦卒中) is the volume of the str
PAT 甲級1035 Password(模擬)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always so
PAT甲級解題目錄(完)
ID Title C/C++程式碼 備註 1001 A+B Format (20) 程式碼 字串處理 1002 A+B for Polynomia
PAT甲級真題——1008 Elevator (20 分)
1008 Elevator (20 分) The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers de
1124 Raffle for Weibo Followers(20 分)(PAT甲級真題)
大佬們大部分都用的map,我只用了string,比map麻煩一點。作為另一種思路,僅供參考。 題目如下: John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽獎) for his fol
PAT甲級真題題解(更新中)
2018年11月17日 13:27:17 Czq6666 閱讀數:9 標籤: pat甲級 資料結構
PAT甲級真題——1011 World Cup Betting (20 分)
1011 World Cup Betting (20 分) With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the bes
PAT甲級真題(二分)——1010 Radix (25 分)
1010 Radix (25 分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is “yes”, if 6 is a
PAT甲級真題(動態規劃)——1007 Maximum Subsequence Sum (25 分)
1007 Maximum Subsequence Sum (25 分) Given a sequence of K integers { N1, N2 , …, NK }. A continuous subsequence is defined to be { Ni, Ni+
PAT甲級真題(字串)——1006 Sign In and Sign Out (25 分)
1006 Sign In and Sign Out (25 分) At the beginning of every day, the first person who signs in the computer room will unlock the door, and the
PAT甲級真題(字串)——1005 Spell It Right (20 分)
1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of t
PAT甲級真題(並查集)——1004 Counting Leaves (30 分)
1004 Counting Leaves (30 分) A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no
1084 Broken Keyboard (20 分) PAT甲級真題
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on sc
PAT甲級水題 A+B in Hogwarts(java string中分隔符的用法)
說明 c中 wid html get mage 轉義字符 split方法 bsp A+B in Hogwarts 在java.lang包中有String.split()方法,返回是一個數組 我在應用中用到一些,給大家總結一下,僅供大家參考: 1、如果用“.”作為分
PAT 甲級真題題解(121-155)
push str print lower while push_back tin c99 題解 1121 Damn Single 模擬 1 // 1121 Damn Single 2 #include <map> 3 #include &l
PAT 甲級 1008 Elevator
const ets stop contain move highlight div all NPU https://pintia.cn/problem-sets/994805342720868352/problems/994805511923286016 The hig
PAT乙級試題整理(二)——牛客網20分真題整理
牛客網上 共有真題六套,其中每套題有15分題一道,20分題目3道,25分題目1道,共計100分。考試時要求考生在180分鐘內完成,依照陳越姥姥的說法,要在30分鐘內拿下乙級20分題目,所以我們這篇主要想辦法怎麼儘量縮短自己的做題時間。我之前只學過Java和C#,沒有學過C語言,粗
PAT乙級試題整理(一)——牛客網15分真題整理
牛客網上 共有真題六套,其中每套題有15分題一道,20分題目3道,25分題目1道,共計100分。考試時要求考生在180分鐘內完成。我之前只學過Java和C#,沒有學過C語言,粗淺學習了一下C語言基本語法,想借刷題這個機會好好體會一下面向過程的設計語言的精髓。這裡計劃: 1.先說題