• 团体程序设计天梯赛 L1-016~L1-020


    L1-016

    思路:

    按题意操作即可

    代码:

    #include<bits/stdc++.h>
    
    using namespace std;
    
    const int p = 17;
    const int mod = 11;
    int w[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
    int m[] = {1, 0, 11, 9, 8, 7, 6, 5, 4, 3, 2};
    
    bool ok(string& s) {
    	int ans = 0;
    	for(int i = 0; i < p; i++) {
    		int now = s[i] - '0';
    		ans += now * w[i];
    	}
    	int mm = s[p] == 'X' ? 11 : s[p] - '0';
    	return mm == m[ans % mod];
    }
    int main() {	
    	int n;
    	cin >> n;
    	vector<string> v;
    	for(int i = 0; i < n; i++) {
    		string s;
    		cin >> s;
    		if(!ok(s)) v.push_back(s);	
    	}
    	if(v.size() == 0) puts("All passed");
    	else for(string& s : v) puts(s.c_str());
    	return 0;
    }
    

    L1-017

    思路:

    按题意操作即可,注意输出精度

    代码:

    #include<bits/stdc++.h>
    
    using namespace std;
    
    int main(){	
    	double a = 0, b, c = 1, d = 1;
    	string s;
    	cin >> s;
    	b = s.length();
    	for(char& c : s) if(c == '2') a += 1;
    	if(((s[b - 1] - '0') & 1) == 0) d = 2;
    	if(s[0] == '-') c = 1.5, --b;
    	printf("%.2f%%", 100.0 * a / b * c * d);
    	return 0;
    }
    

    L1-018

    思路:

    按题意操作即可

    代码:

    #include<bits/stdc++.h>
    
    using namespace std;
    
    int main(){	
    	int a, b;
    	cin >> a;
    	getchar();
    	cin >> b;
    	if(a * 60 + b <= 12*60) printf("Only %02d:%02d.  Too early to Dang.", a, b);
    	else{
    		int num = a - 12 + !!b;
    		while(num--) cout << "Dang";	
    	}
    	return 0;
    }
    

    L1-019

    思路:

    按题意进行模拟

    代码:

    #include<bits/stdc++.h>
    
    using namespace std;
    
    int main(){	
    	int x, y, n;
    	cin >> x >> y >> n;
    	int xx = 0, yy = 0;
    	while(n--){
    		int a, b, c, d;
    		cin >> a >> b >> c >>d;
    		bool _x = (b == a + c);
    		bool _y = (d == a + c);
    		if(_x == 1 && _y == 0) 	++xx;
    		else if(_x == 0 && _y == 1) ++yy;
    		if(xx > x) cout << "A
    " << yy, exit(0);
    		if(yy > y) cout << "B
    " << xx, exit(0);
    	}
    }
    

    L1-020

    思路:

    开个数组映射一下即可;

    代码:

    #include<bits/stdc++.h>
    
    using namespace std;
    
    const int maxn = 123456;
    bool tag[maxn];
    
    int main(){	
    	int n, k, m, x;
    	cin >> n;
    	while(n--){
    		cin >> k;
    		for(int i = 0; i < k; i++){
    			cin >> x;
    			if(k > 1) tag[x] = true;
    		}
    	}
    	cin >> m;
    	vector<int> rs;
    	while(m--){
    		cin >> x;
    		if(tag[x] == false) rs.push_back(x), tag[x] = true;
    	}
    	if(rs.size()){
    		printf("%05d", rs[0]);
    		for(int i = 1; i < rs.size(); i++) printf(" %05d", rs[i]); 	
    	}
    	else puts("No one is handsome");
    	return 0;
    }
    
  • 相关阅读:
    va_start、va_end、va_list的使用
    UNIX环境高级编程 apue.h头文件的配置
    Ant编译android程序
    Shell编程中Shift的用法
    命令生成和运行android项目
    ubuntu rar文件解压中文乱码问题
    SQLite区分大小写查询
    java命令执行jar包的方式
    ubuntu下安装与卸载软件方法
    linux下查看最后登陆的用户的信息
  • 原文地址:https://www.cnblogs.com/yuhan-blog/p/12308694.html
Copyright © 2020-2023  润新知