O2优化什么鬼!

P2010 [NOIP2016 普及组] 回文日期

无欢 @ 2018-02-03 14:11:45

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
struct node
{
    char d[17];
};
node c[17];
char a[9],b[9],e[17],len=0;
int se[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int year1,moon1,date1;
int year2,moon2,date2;
int i,j,k,sum=0;
int main()
{
    k=0;
    i=0;
    while(len<16)
    {
        scanf("%s",c[i].d);
        for(j=0;j<=strlen(c[i].d)-1;j++)
        {
            e[k]=c[i].d[j];
            k++;
        }
        len+=strlen(c[i].d);
        i++;
    }
    for(i=0;i<=7;i++)
    {
        a[i]=e[i];
        b[i]=e[i+8];
    }
    year1=(a[0]-'0')*1000+(a[1]-'0')*100+(a[2]-'0')*10+(a[3]-'0')*1;
    year2=(b[0]-'0')*1000+(b[1]-'0')*100+(b[2]-'0')*10+(b[3]-'0')*1;
    moon2=(b[4]-'0')*10+(b[5]-'0')*1;
    date2=(b[6]-'0')*10+(b[7]-'0')*1;
    for(i=year1;i<=year2;i++)
    {
        moon1=(i/1%10*10)+(i/10%10*1);
        date1=(i/100%10*10)+(i/1000%10*1);
        if(moon1!=2)
        {
            if(i!=year2)
            {
                if(date1<=a[moon1])
                {
                    sum++;
                }
            }
            else
            {
                if(moon1<moon2)
                {
                    sum++;
                }
                if(moon1==moon2)
                {
                    if(date1<=date2)
                    {
                         sum++;
                    }
                }
            }
        }
        else
        {
            if((i%4==0&&i%100!=0)||(i%400==0))
            {
                if(i!=year2)
                {
                    if(date1<=29)
                    {
                        sum++;
                    }
                }
                else
                {
                    if(moon1<moon2)
                    {
                        if(date1<=se[moon1])
                        {
                            sum++;
                        }
                    }
                    if(moon1==moon2)
                    {
                        if(date1<=date2)
                        {
                             sum++;
                        }
                    }
                }
            }
            else
            {
                if(i!=year2)
                {
                    if(date1<=28)
                    {
                        sum++;
                    }
                }
                else
                {
                    if(moon1<moon2)
                    {
                        if(date1<=se[moon1])
                        {
                            sum++;
                        }
                    }
                    if(moon1==moon2)
                    {
                        if(date1<=date2)
                        {
                             sum++;
                        }
                    }
                }
            }
        }
    }
    cout<<sum;
    return 0;
}

没有O2优化60分 O2后70分 谁能告诉我O2优化是干嘛的!


by darkname @ 2019-08-07 23:18:30


by cirnovsky @ 2019-08-11 14:35:57

#pragma GCC optimize (3, "inline", "Ofast")

by xu_z @ 2019-08-31 21:14:38

后排表示无能为力


by wmy_goes_to_thu @ 2019-10-05 19:24:02

O1 O2 O3 Ofast还有神马


by uliahradri @ 2019-11-08 09:11:44

给编译器吸氧,使编译器搞出的程序运行速度更快.


by OwlOwl @ 2020-02-01 19:25:04

@AH_dark 然后被臭氧的鱼腥味毒死


by songhongyi @ 2020-05-10 18:23:41

1考古


by sword_tail @ 2020-05-10 18:38:19

考古


by 不咕鸟 @ 2020-06-06 23:44:37

考古


by CodePenguin @ 2020-07-04 10:39:14

考古


上一页 | 下一页