无欢 @ 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 kin_qidain @ 2021-07-03 11:17:51
@Lonely_zongqing 讲人话谢谢
by cleverxia @ 2021-07-23 21:40:34
我也是 题目P1130
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,k[3000][3000],dp[3000][3000];
int main() {
cin>>n>>m;
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)cin>>k[i][j];
for(int j=1;j<=n;j++)
for(int i=1;i<=m;i++){dp[j][i]=
min(dp[j-1][(i==1?m:i-1)],dp[j-1][i])+k[i][j];
//cout<<i<<' '<<j<<' '<<dp[j][i]<<endl;
}
for(int i=2;i<=m;i++)dp[n][i]=min(dp[n][i],dp[n][i-1]);
cout<<dp[n][m];
return 0;
}
在洛谷上是AC
但是在另一个评测机上T了
开了O2 AC了
这是什么回事?
by Cyril_Nott @ 2021-08-14 19:39:15
考古
by yizhitan @ 2021-10-13 21:22:55
我是从来不用这些乱八七糟的东西的。
by FateReset_ @ 2021-10-16 23:53:25
@Aaron_Liu 开O3给评测姬吸点臭氧