CSP2015-09
CSP201509-1 数列分段
1 // 2 // main.cpp 3 // CSP201509-1 数列分段 4 // 5 // Created by sylvia on 2021/10/31. 6 // Copyright © 2021 apple. All rights reserved. 7 // 8 9 #include <iostream> 10 #include <stdio.h> 11 using namespace std; 12 13 int n,y,x,ans=0; 14 int main(){ 15 cin>>n; 16 y=-1; 17 while (n--){ 18 cin>>x; 19 if (x!=y){ 20 ans++; 21 } 22 y=x; 23 } 24 cout<<ans<<endl; 25 }
CSP201509-2 日期计算
1 // 2 // main.cpp 3 // CSP201509-2 日期计算 4 // 5 // Created by sylvia on 2021/10/31. 6 // Copyright © 2021 apple. All rights reserved. 7 // 8 #include <iostream> 9 #include <stdio.h> 10 #include <math.h> 11 #include <algorithm> 12 #include <string.h> 13 using namespace std; 14 #define M 1000+5 15 int y,d; 16 int month=0,day=0; 17 int mon[13]={0,31,0,31,30,31,30,31,31,30,31,30,31}; 18 int judge(int y){ 19 if(!(y%400)) return 29; 20 if(!(y%4)&&(y%100)) return 29; 21 return 28; 22 } 23 int main(){ 24 cin>>y>>d; 25 mon[2]=judge(y); 26 for (int i=1;i<=12;i++){ 27 if(d-mon[i]>0) { 28 month++; 29 d-=mon[i]; 30 } else break; 31 } 32 month++; 33 day=d; 34 cout<<month<<endl<<day<<endl; 35 36 return 0; 37 }