【题解】NOIP201601&02

NOIP201601

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch==‘-‘) f=-1;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-‘0‘;
    return x*f;
}

int n,ans=1000000;

int main()
{
    n=read();
    for(int i=0;i<3;i++)
    {
        int a=read(),b=read();
        if( n % a == 0) ans=min(ans,(n/a)*b);
        else ans=min(ans,(n/a+1)*b);
    }
    printf("%d\n",ans);
}

NOIP201602

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch==‘-‘) f=-1;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-‘0‘;
    return x*f;
}

int n,m,a[8],b[8],now,ans;

bool rn(int year)
{
    if( (year % 4 == 0 && year % 100 != 0) || year % 400 == 0 ) return true;
    return false;
}

int main()
{
    n=read(),m=read();
    while(n > 0)
    {
        a[now++]=n%10;
        n/=10;
    }
    now=0;
    while(m > 0 )
    {
        b[now++]=m%10;
        m/=10;
    }

    for(int i=0;i<4;i++) swap(a[i],a[7-i]),swap(b[i],b[7-i]);

    int 

        nyear=a[0]*1000+a[1]*100+a[2]*10+a[3],
        nmonth=a[4]*10+a[5]-1,
        nday=a[6]*10+a[7],

        myear=b[0]*1000+b[1]*100+b[2]*10+b[3],
        mmonth=b[4]*10+b[5]-1,
        mday=b[6]*10+b[7],

        month[12]={31,0,31,30,31,30,31,31,30,31,30,31};

    for(int i=nyear;i<=myear;i++)
    {
        if( rn(i)) month[1]=29;
        else month[1]=28;

        int nowy[4],tmp=i;now=0;
        while( tmp > 0)
        {
            nowy[now++]=tmp%10;
            tmp/=10;
        }
        for(int j=0;j<2;j++) swap(nowy[j],nowy[3-j]);

        int
            dd=nowy[0]+nowy[1]*10,
            mm=nowy[2]+nowy[3]*10-1;

        if( dd > month[mm] || dd <= 0 || mm >= 12 || mm < 0 ) continue;

        if( i == nyear )
        {
            if( mm < nmonth || mm > 13 ) continue;
            if( dd < nday || dd > month[nmonth] ) continue;
        }
        else if( i == myear )
        {
            if( mm > mmonth) continue;
            if( dd < nday || dd > month[mmonth] ) continue;
        }

        ans++;
        month[1]=0;
    }

    printf("%d\n",ans);
}
时间: 2025-01-12 02:27:29

【题解】NOIP201601&02的相关文章

【分享】近4000份数学学习资源免费分享给大家

一直以来喜欢收集数学类的教程资源,于是费了好大劲从万千合集站上扒拉了下来,总结归类了一下,一共有将近4000本电子书.经测试,均可免费下载,可能会弹出小广告,可不必理会之.[仅供学术学习和交流,请无用于商业用途.]另外,如有可能,还请尽量支持正版纸质书.   数学史(54)     数学史.rar 55.6 MB   数学的起源与发展.rar 4.3 MB   费马大定理—一个困惑了世间智者358年的谜.pdf 9.5 MB   通俗数学名著译丛14-无穷之旅:关于无穷大的文化史.pdf 14.

百度刚放假啊数据库风口浪尖萨拉疯了

http://www.ebay.com/cln/l_x5585/2015.02.11/176746639012 http://www.ebay.com/cln/jiacha_boryk/2015.02.11/176837188016 http://www.ebay.com/cln/gbnlin0/2015.02.11/176837189016 http://www.ebay.com/cln/j_j2841/2015.02.11/177066749015 http://www.ebay.com/c

百度房间爱师傅卡卡是快乐疯了;爱死

http://www.ebay.com/cln/shx9479/-/177007606013/2015.02.11 http://www.ebay.com/cln/genqi12/-/176846034010/2015.02.11 http://www.ebay.com/cln/seyyon2/-/176906811016/2015.02.11 http://www.ebay.com/cln/wcn5971/-/176846032010/2015.02.11 http://www.ebay.co

百度和房价是否健康教案上开发

http://www.ebay.com/cln/l.kuan2/-/167247714018/2015.02.10 http://www.ebay.com/cln/setlia-3616/-/167086016019/2015.02.10 http://www.ebay.com/cln/pen-y77/-/167086017019/2015.02.10 http://www.ebay.com/cln/yua-me2/-/167399441016/2015.02.10 http://www.eba

百度电话费健身房拉伸件礼服加拉斯减肥

http://www.ebay.com/cln/cnli_c90nphs5e/-/167379958016/2015.02.07 http://www.ebay.com/cln/gaw4612/-/167226239018/2015.02.07 http://www.ebay.com/cln/re_len4/-/167263594010/2015.02.07 http://www.ebay.com/cln/ta.ku83/-/167162702017/2015.02.07 http://www.

百度回复金卡是减肥拉进来收付款

http://www.ebay.com/cln/cnli_c90nphs5e/-/167379958016/2015.02.08 http://www.ebay.com/cln/gaw4612/-/167226239018/2015.02.08 http://www.ebay.com/cln/re_len4/-/167263594010/2015.02.08 http://www.ebay.com/cln/ta.ku83/-/167162702017/2015.02.08 http://www.

百度放假哈萨克就发了设计费拉萨

http://www.ebay.com/cln/ldicn.mz6dm/2015.02.11/177030163015 http://www.ebay.com/cln/tan_qi5/2015.02.11/176903144013 http://www.ebay.com/cln/l.lu104/2015.02.11/177030175015 http://www.ebay.com/cln/ya01191/2015.02.11/176722580014 http://www.ebay.com/cl

百度房间撒谎发卡上就发了空间啊

http://www.ebay.com/cln/h-h4129/2015.02.11/176819191016 http://www.ebay.com/cln/fendo88/2015.02.11/176613943017 http://www.ebay.com/cln/ygon288/2015.02.11/176727517018 http://www.ebay.com/cln/ta.ch17/2015.02.11/176613950017 http://www.ebay.com/cln/g-

百度房间沙发客服就考试考几分离开

http://www.ebay.com/cln/jinlon8/book/167309734010/2015.02.10 http://www.ebay.com/cln/bam5330/book/167115292019/2015.02.10 http://www.ebay.com/cln/yi_za70/book/167315676012/2015.02.10 http://www.ebay.com/cln/y.y3463/book/167285977014/2015.02.10 http:/