上海市计算机学会月赛2021年4月丙组
 发布时间 
 阅读量: 
 阅读量 
数人数
    #include <iostream>
    #include <cstdio>
    using namespace std;
    
    int main() {
    	int a, b;
    	cin >> a >> b;
    	
    	for (int i = 1; ; i ++) {
    		int j = i + a;
    		if (j-b == 2*(i-b)) {
    			cout << j << endl;
    			cout << i << endl;
    			return 0;
    		}
    	} 
    
    
    	return 0;
    }
        猴子吃桃
    #include <iostream>
    #include <cstdio>
    using namespace std;
    
    int main() {
    	int n, a;
    	cin >> n >> a;
    	
    	for (int i = n; i >= 1; i --) {
    		a = (a-1) * 2;
    	} 
    	cout << a;
    
    	return 0;
    }
        巧妙的数 60分
    #include <iostream>
    #include <cstdio>
    using namespace std;
    
    int main() {
    	long long n, t;
    	cin >> n;
    	t = n;
    	
    	while (t) {
    		if (t%10!=0 && n%(t%10)!=0) {
    			cout << "not clever";
    			return 0;
    		}
    		t /= 10;
     	}
    	cout << "clever"; 
    	
    	return 0;
    }
        巧妙的数 100分
    #include <iostream>
    #include <cstdio>
    using namespace std;
    
    bool mt[10];
    int a[1010], n;
    char ch;
    
    int main() {
    	while (cin >> ch) {
    		a[++n] = ch - '0';
    		mt[a[n]] = true;
    	}
    	
    	for (int i = 2; i <= 9; i ++) {
    		if (mt[i]) {
    			int r = 0;
    			for (int j = 1; j <= n; j ++) {
    				r = (r * 10 + a[j]) % i;
    			}
    			if (r != 0) {
    				cout << "not clever";
    				return 0;
    			}
    		}		
    	} 
    	
    	cout << "clever";
    	
    	return 0;
    }
        没有考试的天数
    #include <iostream>
    using namespace std;
    
    int gcd(int x, int y) {
    	if (y == 0) return x;
    	return gcd(y, x%y);
    }
    
    int main() {
    	int n, a, b, c;
    	cin >> n >> a >> b >> c;
    	
    	int d = a / gcd(a, b) * b;
    	int e = b / gcd(b, c) * c;
    	int f = c / gcd(c, a) * a;
    
    	int g = d / gcd(d, c) * c;
    	
    	cout << n - (n/a + n/b + n/c) + (n/d + n/e + n/f) - n/g;
    	
    	return 0;
    }
        考试排名
    #include <iostream>
    #include <algorithm>
    using namespace std;
    
    int n;
    struct classes{
    	int a[4];
    	double b[4];
    	int num, id;
    }cls[10005];
    
    bool cmp(classes x, classes y) {
    	if (x.b[0] > y.b[0]) return true;
    	if (x.b[0] == y.b[0]) {
    		if (x.b[1] > y.b[1]) return true;
    		if (x.b[1] == y.b[1]) {
    			if (x.b[2] > y.b[2]) return true;
    			if (x.b[2] == y.b[2]) {
    				if (x.b[3] > y.b[3]) return true;
    				if (x.b[3] == y.b[3]) {
    					if (x.num > y.num) return true;
    					if (x.num == y.num) {
    						if (x.id < y.id) return true;
    					}
    				}
    			}
    		}
    	}
    	
    	return false;
    }
    
    int main() {
    	cin >> n;
    	
    	for (int i = 1; i <= n; i ++) {
    		string s;
    		cin >> s;
    		int len = s.size();
    		for (int j = 0; j < len; j ++) {
    			int t = s[j] - 'A';
    			cls[i].a[t] ++;
    		}
    		
    		for (int j = 0; j < 4; j ++) {
    			cls[i].b[j] = cls[i].a[j] * 1.0 / len;
    		}
    		
    		cls[i].num = len;
    		cls[i].id = i;
    	}
    
    	sort(cls+1, cls+1+n, cmp);
    	
    	for (int i = 1; i <= n; i ++) cout << cls[i].id << ' ';
    
    	return 0;
    }
        全部评论 (0)
 还没有任何评论哟~ 
