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;
    }
    
  • 相关阅读:
    mybatis :xml文件中传入参数和if标签结合使用时要点
    mysql:查询数据库版本的几种方式
    http post 方法传递参数的2种方式
    深入理解mybatis参数
    Mybatis:动态sql
    Mybatis:传入参数方式以及#{}与${}的区别
    [GLSL]着色器周记02——火焰特效 【转】
    OpenGL ES入门09-GLSL实现常见特效 [转]
    RenderMonkey 练习 第五天 【OpenGL NormalMapping】
    反射向量 及 向量投影
  • 原文地址:https://www.cnblogs.com/yuhan-blog/p/12308672.html
Copyright © 2011-2022 走看看