zoukankan      html  css  js  c++  java
  • P1664 每日打卡心情好

    题目如下:

     思路:

    读清楚题意,然后就是要自信喔。你能做出来的

    代码如下:

    #include<cstdio> 
    #include<iostream>
    #include<cmath>
    using namespace std;
    int main(){
        int n,flag,l=0,sum=0,m=0;
        cin>>n;
        int a[n+1];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            if(a[i]){ 
            if(m>0){
            l-=pow(2,m-1) ;
            if(l<0)
            //不要忽略 一开始就是0的情况
            l=0;
            }
            m=0;        //遗漏的天数 
            l++;    //连续天数 
            if(l>=1&&l<3){
            sum+=1;
    //        cout<<sum<<endl; 
            }
            else if(l>=3&&l<7){
            sum+=2;
    //        cout<<sum<<endl;
            }
            else if(l>=7&&l<30){
                sum+=3;
    //            cout<<sum<<endl;
            }
    
            else if(l>=30&&l<120)
            sum+=4;
            else if(l>=120&&l<365)
            sum+=5;
            else if(l>=365)
            sum+=6;
            }
            else
            { m++;
            }
        }
        cout<<sum<<endl;
        return 0;
    }
    
     
    无聊就学习 反正没事干
  • 相关阅读:
    9.17考试
    Something
    tesuto-Mobius
    7.22考试
    填坑...P1546 最短网络 Agri-Net
    P1125 笨小猴
    P2822 组合数问题
    致我们曾经刷过的水题
    Luogu P1186 玛丽卡
    Luogu P1726 上白泽慧音
  • 原文地址:https://www.cnblogs.com/miao-xixixi/p/12805751.html
Copyright © 2011-2022 走看看