TinaCristal's Blog


  • Home

  • Tags

  • Categories

  • Archives

  • Search

2018-03-1 跳一跳

Posted on 2018-11-22 | In ccf认证 |

tmp记录上一次跳的值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<iostream>
using namespace std;
int main(){
int a;
int plus=0,tmp;
int sum=0;
while(1){
scanf("%d",&a);
if(a==0) break;
if(a==1){
sum+=1;
}
else
{
if(tmp==2) plus+=2;
else plus=2;
sum+=plus;
}
tmp=a;


}
cout<<sum<<endl;

}

LeetCode 763. Partition Labels
vector的几种初始化及赋值方式:

TinaCristal

443 posts
57 categories
55 tags
GitHub E-Mail
© 2020 TinaCristal
Powered by Hexo
|
Theme — NexT.Mist v5.1.4