上海市计算机学会月赛2020年5月丙组
 发布时间 
 阅读量: 
 阅读量 
戴口罩
    #include <cstdio>
    #include <iostream>
    using namespace std;
    
    int main() {
    	int n, days = 3, kz = 10;
    	cin >> n;
    	
    	while (kz != n) {
    		kz -- ;
    		if (days%7 == 1 || days%7 == 2) kz += 7;
    
    		days ++ ;
    	}
    
    	cout << days - 3;
    
    	return 0;
    }
        计算GPA
    #include <cstdio>
    #include <iostream>
    using namespace std;
    
    int main() {
    	double gpa = 0;
    	int cnt = 0;
    
    	string s;
    	getline(cin, s);
    	
    	for (int i = 0; i < s.size(); i ++ ) {
    		if (s[i] == '+') {
    			gpa += 0.3;
    		}
    		else if (s[i] == '-') {
    			gpa -= 0.3;
    		}
    		else {
    			gpa += 69 - s[i];
    			cnt ++ ;
    		}
    	}
    	
    	printf("%.2lf", gpa / cnt);
    
    	return 0;
    }
        扫雷
    #include <cstdio>
    #include <iostream>
    using namespace std;
    
    int n, m;
    char a[105][105];
    
    int f(int x, int y) {
    	int ans = 0;
    	
    	for (int i = x - 1; i <= x + 1; i ++ ) {
    		for (int j = y - 1 ; j <= y + 1; j ++ ) {
    			if (a[i][j] == '*') ans ++ ;
    		}
    	}
    	return ans;
    }
    
    int main() {
    	cin >> n >> m;
    	
    	for (int i = 1; i <= n; i ++ ) {
    		for (int j = 1; j <= m; j ++ ) {
    			cin >> a[i][j];
    		}
    	}
    
    	for (int i = 1; i <= n; i ++ ) {
    		for (int j = 1; j <= m; j ++ ) {
    			if (a[i][j] == '*') cout << '*';
    			else cout << f(i,j);
    		}
    		cout << endl;
    	}
    
    	return 0;
    }
        增长或翻倍
    #include <cstdio>
    #include <iostream>
    using namespace std;
    
    int main() {
    	int s, t, ans = 0;
    	
    	cin >> s >> t;
    	
    	while (s < t) {
    		if (t % 2 == 1) t --;
    		else if (t/2 >= s) t /= 2;
    		else break;
    		
    		ans ++ ;
    	}
    	ans += t - s;
    
    	cout << ans;
    
    	return 0;
    }
        最大回撤
    #include <cstdio>
    #include <iostream>
    using namespace std;
    
    int n, a, maxPrice = -1e5, maxLoss = -1e9;
    
    int main() {
    	cin >> n;
    	
    	for (int i = 1; i <= n; i ++) {
    		cin >> a;
    		maxPrice = max(maxPrice, a);
    		maxLoss = max(maxLoss, maxPrice - a);
    	}
    
    	cout << maxLoss;
    	
    	return 0;
    }
        全部评论 (0)
 还没有任何评论哟~ 
