~~那就加个1呗~~
by R·Buffoon @ 2019-05-25 16:26:27
@[R·Buffoon](/space/show?uid=171014)
~~然后目前为止拿到10分~~(已经试过了)
by Petris_H_07 @ 2019-05-25 17:33:42
@[R·Buffoon](/space/show?uid=171014) 话说回来竟然遇到个红名锦依卫大佬
by Petris_H_07 @ 2019-05-25 17:34:58
输出时ans+1得90分
话说$\color{#66ccff}\text{tianyi}$没错吧
by R·Buffoon @ 2019-05-25 17:48:47
~~~
#include <iostream>
using namespace std;
int road[10005];
int start[105],end[105];
int main()
{
int l,m;
cin>>l>>m;
for (int i=0;i<=l;i++) road[i]=1;
for (int j=0;j<m;j++)
{
cin>>start[j]>>end[j];
}
for (int k=0;k<m;k++)
{
int tianyi=start[k];
while (tianyi<=end[k])
{
road[tianyi]=0;
++tianyi;
}
}
int ans=0;
for (int n=0;n<=l;n++)
{
if (road[n]!=0) ans+=1;
}
cout<<ans<<endl;
return 0;
}
by R·Buffoon @ 2019-05-25 17:54:45
@[Petris_H_07](/space/show?uid=146344)
by R·Buffoon @ 2019-05-25 17:56:15
@[R·Buffoon](/space/show?uid=171014) 如果指颜色的话没错的应该
by Petris_H_07 @ 2019-05-25 18:43:50
@[R·Buffoon](/space/show?uid=171014) while里面为啥改成了++tianyi
by Petris_H_07 @ 2019-05-25 18:45:20
为啥if去掉就没问题了……orz
by Petris_H_07 @ 2019-05-25 18:48:28
@[Petris_H_07](/space/show?uid=146344)
~~~
while (tianyi<=end[k])
~~~
要小于等于,小于的话会少砍一棵树
if去不去没差别
~~~
tianyi+=1;
~~~
与
~~~
++tianyi
~~~
是等价的,个人习惯
~~~
int tianyi=start[k]-1;
~~~
没必要减1,减1就多砍一棵树了
by R·Buffoon @ 2019-05-25 19:22:54