文章

35

粉丝

0

获赞

144

访问

7.3k

头像
机试奥义,能用for循环跑出来继续
P1175 清华大学上机题
发布于2025年3月14日 19:14
阅读数 236

#include <bits/stdc++.h>
using namespace std;
int main() {
    int L,M;
    while(cin>>L>>M){
    	vector<int> t(L+1,1);
    	int start,end;
    	for(int i=0;i<M;i++){
    		cin>>start>>end;
    		for(int j=start;j<=end;j++){
    			t[j]=0;
			}
		}
		int s=0;
		for(int i=0;i<t.size();i++){
			if(t[i]==1) s++;
		}
		cout<<s<<endl;
	}
    
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发