zoukankan      html  css  js  c++  java
  • 团体程序设计天梯赛 L1-056~L1-060

    L1-056

    思路:

    这里算出来相减排个序即可

    代码:

    #include<bits/stdc++.h>
    
    using namespace std;
    
    typedef pair<int, string> P;
    
    int main() {	
    	int n, ans = 0;
    	cin >> n;
    	vector<P> v;
    	for(int i = 0; i < n; i++){
    		string s;
    		int num;
    		cin >> s >> num;
    		v.push_back(P(num, s));
    		ans += num;
    	}
    	ans = int(1.0 * ans / n / 2);
    	cout << ans << ' ';
    	for(P & p : v) p.first = abs(p.first - ans);
    	sort(v.begin(), v.end());
    	cout << v[0].second;
    	return 0;
    }
    

    L1-057

    思路:

    实在不想打出这句骗人的话

    代码:

    #include<bits/stdc++.h>
    
    using namespace std;
    
    int main() {	
    	puts("PTA shi3 wo3 jing1 shen2 huan4 fa1 !");
    	return 0;
    }
    

    L1-058

    思路:

    这题不要用空格将它们分开,老老实实挨个循环吧

    代码:

    #include<bits/stdc++.h>
    
    using namespace std;
    
    int main() {	
    	string s;
    	getline(cin, s);
    	for(int i = 0; i < s.length(); i++){
    		if(s[i] != '6') { putchar(s[i]); continue; }
    		for(int j = i; j < s.length(); j++){
    			if(j + 1 == s.length() || s[j + 1] != '6'){
    				int len = j - i + 1;
    				if(len > 9) { cout << 27; i = j; break; }
    				else if(len > 3) { cout << 9; i	= j; break; }
    				else { cout << s.substr(i, len); i = j; break; }
    			}
    		}
    	}
    	return 0;
    }
    

    L1-059

    思路:

    这题略恶心 ,模拟吧

    代码:

    #include<bits/stdc++.h>
    
    using namespace std;
    
    bool ok(string & s){
    	string cmp = "ong";
    	int x = s.find(','), y = s.find('.');
    	if(x < 3) return false;
    	if(s.substr(x - 3, 3) != cmp || s.substr(y - 3, 3) != cmp) return false;
    	reverse(s.begin(), s.end());
    	for(int i = 0; i < 3; i++){
    		int pos = s.find(' ');
    		s = s.substr(pos + 1);	
    	}
    	reverse(s.begin(), s.end());
    	return true;
    }
    
    int main() {	
    	int n;
    	cin >> n;
    	getchar();
    	while(n--){
    		string s;
    		getline(cin, s);
    		if(ok(s)) cout << s << " qiao ben zhong.
    ";
    		else cout << "Skipped
    ";	
    	}
    	return 0;
    }
    

    L1-060

    思路:

    大面积减小面积

    代码:

    #include<bits/stdc++.h>
    
    using namespace std;
    
    #define s(x, y) ((x) * (y) / 2)
    int main() {	
    	int x, y;
    	cin >> x >> y;
    	cout << 5000 - s(x, y) - (100 -x) * y - s(100 - x, 100 -y);
    	return 0;
    }
    
  • 相关阅读:
    axios+post获取并下载后台返回的二进制流
    vue+ckEditor5
    金额大写转换(改进版)
    vue+axios请求头封装
    移动端h5+vue失焦搜索,ios和android兼容问题
    vue滚动+滑动删除标记(移动端)仿qq/微信
    重置 centos 7 密码
    发现好玩的——github + git 有意思的用法
    github 中使用 issues
    java代理模式与装饰模式
  • 原文地址:https://www.cnblogs.com/yuhan-blog/p/12308672.html
Copyright © 2011-2022 走看看