跳到正文

个人记录

河西-8.1上午3教室-廖

chengyuha约 6 分钟
原文
文章信息与版本

文章信息

发布
2025年8月1日
收录
2025年12月12日
更新
2026年11月16日
篇幅
约 6 分钟
获赞
1

版本

  1. v1当前

T2

C++
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,x,y,ans=0,an=0;
    cin>>n>>x>>y;
    for(int i=0;i<n;i++){
		if(ans%y==0){
			an++;
		}
		ans+=x;
	} 
	cout<<an;
    return 0;
}

错误点:没开long long

T4

C++
#include <bits/stdc++.h>
using namespace std;
int b[109],t[20009];
int a,ans=0;
int cheak(int x){
	for(int i=1;i<=a;i++){
		if(x==b[i]){
			return 1;
		}
	}
	return 0;
}
int main(){
    cin>>a;
    for(int i=1;i<=a;i++){
    	cin>>b[i];
	}
    for(int i=1;i<=a;i++){
    	for(int j=i+1;j<=a;j++){
    		if(cheak(b[i]+b[j])==1&&t[b[i]+b[j]]==0){
    			ans++;
    			t[b[i]+b[j]]=1;
			}
		}
	}
	cout<<ans;
    return 0;
}

错误点:没有去重

T5

C++
#include <bits/stdc++.h>
using namespace std;
int cheak(int x){
	int ans=0;
	while(x>0){
		ans+=x%10;
		x/=10;
	}
	return ans;
}
int main(){
	int n;
	cin>>n;
	while(n){
		n--;
    	long long a,ans=0,n=1;
    	cin>>a;
    	while(a>0){
    		int d=a%10;
    		a/=10;
    		if(n%2==0){
    			ans+=d;
			}else{
				d*=7;
				while(d>9){
					d=cheak(d);
				}
				ans+=d;
			}
			n++;
		}
		if(ans%8==0){
			cout<<"T"<<endl;
		}else{
			cout<<"F"<<endl;
		}
	}
    return 0;
}
//程禹豪 

错误点:没开long long

T6

C++
#include <bits/stdc++.h>
using namespace std;
long long a[1000009];
long long n,m;
int cheak(long long x){
	long long ans=0;
	for(int i=1;i<=n;i++){
		ans+=max(0LL,a[i]-x);
	}
	if(ans>=m){
		return 1;
	}
	return 0;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
	}
	long long l=0,r=4e5+5;
	while(l+1<r){
		long long sb=(l+r)/2;
		if(cheak(sb)==1){
			l=sb;
		}
		else{
			r=sb;
		}
	}
	cout<<l;
    return 0;
}

错误点:把 ans看成了x

T7

C++
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string a[] = {"", "Beatrice", "Belinda", "Bella", "Bessie", "Betsy", "Blue", "Buttercup", "Sue"};
string b[10];//放牛的盒子
int v[10];//这头牛有没有用过
int p[10];//存某一头在的盒子里的位置
int n, f; //f为标记是否已经输出
struct st { //存需要在一起的两头牛的编号
	int a, b;
} s[10];
int cheak() { //检查现在存入的牛与牛之间是否满足他们的关系(贴贴)
	for (int i = 1; i <= n; i++) {
		int s1 = s[i].a;
		int s2 = s[i].b;
		if (abs(p[s1] - p[s2]) != 1) {
			return 0;
		}
	}
	return 1;
}
void dfs(int step) {
	if (f == 1) {
		return ;
	}
	if (step > 8) {
		if (cheak() == 1) {
			for (int i = 1; i <= 8; i++) {
				cout << b[i] << endl;
			}
			f = 1; //已经输出过了
		}
		return ;
	}
	for (int i = 1; i <= 8; i++) {
		if (v[i] == 0) { //编号i的牛没有用过
			v[i] = 1; //标记使用
			b[step] = a[i]; //将i号牛的名字存入对应step的盒子里
			p[i] = step; //第i头牛放入第step号位置
			dfs(step + 1); //搜索
			v[i] = 0; //回溯
		}
	}
}
int main() {
	cin >> n;
	for (int j = 1; j <= n; j++) {
		string x, y, z;
		cin >> x >> z >> z >> z >> z >> y;
		int s1;
		for (int i = 1; i <= 8; i++) { 
				if (x == a[i]) {
					s1= i;
				}
			}
		int s2;
		for (int i = 1; i <= 8; i++) { 
						if (y == a[i]) {
							s2= i;
						}
					}
		s[j] = {s1, s2}; //存入两头牛的关系
	}
	dfs(1);//全排列
	return 0;
}
原文