T1T1

考试错误:无

思路:直接循环遍历每一个数,再用数位分离统计即可。

代码:

#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	freopen("tj.in","r",stdin);
	freopen("tj.out","w",stdout);
    int l,r;
    cin >> l >> r;
    int cnt=0;
    for(int i=l;i<=r;i++){
        int x=i;
        while(x){
            if(x%10==2) cnt++;
            x/=10;
        }
    }
    cout << cnt;
}

T2T2

考试错误:无。

思路:都不需要思路,直接按照题目模拟计分即可。

代码:

#include <bits/stdc++.h>
#define int long long
using namespace std;
string s;
signed main(){
	freopen("pingpong.in","r",stdin);
	freopen("pingpong.out","w",stdout);
	char c;
	while(1){
		cin >> c;
		if(c=='E') break;
		s.push_back(c);
	}
	int ww=0,ll=0;
	for(auto x:s){
		if(x=='W') ww++;
		else ll++;
		if(ww>=11&&ww-ll>=2||ll>=11&&ll-ww>=2){
			cout << ww << ":" << ll << endl;
			ww=ll=0;
		}
	}
	cout << ww << ":" << ll << endl << endl;
	ww=ll=0;
	for(auto x:s){
		if(x=='W') ww++;
		else ll++;
		if(ww>=21&&ww-ll>=2||ll>=21&&ll-ww>=2){
			cout << ww << ":" << ll << endl;
			ww=ll=0;
		}
	}
	cout << ww << ":" << ll;
}

T3T3

考试错误:没有做出来。

思路:一道大模拟题,只是考虑的细节比较多而已。

代码:

#include <bits/stdc++.h>
#define int long long
using namespace std;
int m,n,p,cnt;
string name[26],wday[8]={"","Today is Monday.","Today is Tuesday.","Today is Wednesday.","Today is Thursday.", "Today is Friday.","Today is Saturday.","Today is Sunday."};
pair<int,string> stc[111];
int jh=0,fh=0,state[111],st[26];
int get(string s){
	for(int i=1;i<=m;i++){
		if(s==name[i]) return i;
	}
	return -1;
}
int jd(int day,int bad,int now,string s){
	if(s=="I am guilty.") return now!=bad;
	if(s=="I am not guilty.") return now==bad;
	for(int i=1;i<=m;i++){
		if(name[i]+" is guilty."==s){
			return i!=bad;
		}
	}for(int i=1;i<=m;i++){
		if(name[i]+" is not guilty."==s){
			return i==bad;
		}
	}for(int i=1;i<=7;i++){
		if(s==wday[i]){
			return i!=day;
		}
	}
	return -1;
}
bool check(int bad,int day){
	jh=fh=0;
	memset(state,-1,sizeof state);
	for(int i=1;i<=p;i++){
		if(jd(day,bad,stc[i].first,stc[i].second)==1){
			if(state[stc[i].first]==-1) state[stc[i].first]=1;
			if(state[stc[i].first]==0){
				return false;
			}
		}else if(jd(day,bad,stc[i].first,stc[i].second)==0){
			if(state[stc[i].first]==-1) state[stc[i].first]=0;
			if(state[stc[i].first]==1){
				return false;
			}
		}
	}
	for(int i=1;i<=m;i++){
		if(state[i]==1) jh++;
		if(state[i]==-1) fh++;
	}
	return jh<=n&&n<=jh+fh;
}
signed main(){
	freopen("zt.in","r",stdin);
	freopen("zt.out","w",stdout);
	cin >> m >> n >> p;
	for(int i=1;i<=m;i++){
		cin >> name[i];
	}
	for(int i=1;i<=p;i++){
		string first,second;
		cin >> first;
		first.pop_back();
		getline(cin,second);
		second.erase(second.begin());
		stc[i]={get(first),second};
	}
	int bad=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=7;j++){
        	if(check(i,j)&&st[i]==0){
        		st[i]=1;
        		cnt++;
        		bad=i;
			}
		}
	}
	if(cnt>1) cout << "Cannot Determine";
	else if(cnt<1) cout << "Impossible";
	else cout << name[bad];
}

T4T4

待更新......

谢谢😕😕