码迷,mamicode.com
首页 > 其他好文 > 详细

cfround586a\b\c

时间:2019-10-04 13:37:19      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:def   ++i   ace   count   最小   with   codeforce   pac   -o   

https://codeforces.com/contest/1220/problem/A

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) ((x).begin(), (x).end())
int main(){
    int n; string s;
    cin >> n >> s;
    int c0 = count(s.begin(), s.end(), z);
    int c1 = count(s.begin(), s.end(), n);
    //int c0 = count(ALL(s), ‘z‘);
//    int c0 = count(ALL(s), ‘z‘);//?>??
    //int c1 = count(ALL(s), ‘n‘);
//    int c1 = count(ALL(s), ‘n‘), c0;//????
    
    for (int i = 0; i < c1; ++i) { cout << "1 "; }
    for (int i = 0; i < c0; ++i) { cout << "0 "; }
    cout << "\n";
}
/*


*/

https://codeforces.com/contest/1220/problem/B

注意溢出, 精度问题

#include<bits/stdc++.h>
 
using namespace std;
#define _for(i,a,b) for(int i = (a); i < (b); i++)
#define _rep(i,a,b) for(int i = (a); i <= (b); i++)
int n, a[1010][1010];
int main(){
    cin >> n;
    _rep(i,1,n) _rep(j,1,n)  cin>>a[i][j];
    cout<< (int)sqrt(1LL*a[1][n]*a[1][n-1]/a[n][n-1])<< " " << (int)sqrt(1LL*a[2][1]*a[2][3]/a[1][3]) << " ";
    _rep(i,3,n) cout<< (int)sqrt(1LL*a[i][1]*a[i][2]/a[1][2])<<( i==n?"\n":" ");
    return 0;
}
/*
4
0 1 1 1000000000
1 0 1 1000000000
1 1 0 1000000000
1000000000 1000000000 1000000000 0
 
Output
1 1 1 1e+009
Answer
1 1 1 1000000000 
*/

 

 

https://codeforces.com/contest/1220/problem/C

其实就是string的每个字符的前置字符是否有  < ch的, 有的话 Ann 直接移动到最小的那个即可胜利, 否则 输

/*
input 
abba

output 
Mike
Ann
Ann
Mike

input 
cba

output 
Mike
Mike
Mike
*/
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    char minch = z+1;
    for(char ch : s) {
        if(minch < ch) cout<< "Ann\n";
        else cout<<"Mike\n", minch = ch;

    }    
}    

 

cfround586a\b\c

标签:def   ++i   ace   count   最小   with   codeforce   pac   -o   

原文地址:https://www.cnblogs.com/163467wyj/p/11621873.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!