2020.10.16 Rating 补题报告

A - Juggling Letters

题意:给出一些字符串,其中字符可以互相移动交换,问能否使所有字符串都相等

做法:统计所有字母出现的次数,然后再看看能不能被n整除就行

代码:

//去吧马里奥!把AC公主救回来!
//        ********
//       ************
//       ####....#.
//     #..###.....##....
//     ###.......######
//        ...........
//       ##*#######
//    ####*******######
//   ...#***.****.*###....
//   ....**********##.....
//   ....****    *****....
//     ####        ####
//   ######        ######
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<sstream>
#include<cstring>
#include<vector>
#include<iomanip>
#include<queue>
#include<set>
#define LL long long
#define _64 __int64
const double PI = atan(1.)*4.;
using namespace std;



int main(){
    int t;
    cin >> t;
    while(t--){
            int a[2000];
        for(int i= 0;i < 2000;i++){
            a[i] = 0;
        }
        int n;
        cin >> n;
        int num = n;
    while(n--){
        char s[2000];
        cin >> s;
        for(int i = 0;s[i] != 0;i++){
            a[s[i] - 'a']++;
        }
    }

        int flag = 1;
        for(int i = 0;i <= 26;i++){
            if(a[i] % num != 0){
                flag = 0;
                break;
            }
        }
        if(flag == 1){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }

    }
}

B - Power Sequence

题意:给出一串数字,可以进行加减1的操作,最终目的是使其成为一串等比数列,问需要最少多少步

做法:可以暴力枚举,,先排序,之后每个数枚举需要的步数就行

代码:

//去吧马里奥!把AC公主救回来!
//        ********
//       ************
//       ####....#.
//     #..###.....##....
//     ###.......######
//        ...........
//       ##*#######
//    ####*******######
//   ...#***.****.*###....
//   ....**********##.....
//   ....****    *****....
//     ####        ####
//   ######        ######
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<sstream>
#include<cstring>
#include<vector>
#include<iomanip>
#include<queue>
#include<set>
#define LL long long
#define _64 __int64
const double PI = atan(1.)*4.;
using namespace std;

int a[200005];

int main(){

    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
    }
    LL minn = 1e20;
    sort(a+1,a+1+n);
    for(int i = 1;i <= 1000000;i++){
        LL num = 0;
        LL bi = 1;
        for(int j = 1;j <= n;j++){
            num += abs(a[j] - bi);
            if(num > minn){
                break;
            }
            bi = bi * i;
        }
        if(num < minn){
            minn = num;
        }
    }

    cout << minn << endl;

}

 

D - Drinks Choosing

题意:这个题的题意绕的一批,看半天都没看明白是什么意思,大体意思就是输入学生的数量和饮料的种类,然后输入学生想要的饮料的编号,之后这倒霉玩意的意思是饮料都是一组两杯的,两杯一定是同一种饮料,问最多有多少学生能得到自己想要的饮料

做法:首先,得把学生分成两人一组,如果两人想要同一种饮料,那就属于满足的一类,如果两人想要的不一样,那必然只有一个人能够满足需求,把这两组分开后,满足的加上不满足的除以二就是答案了(注意要向上取整)

代码:

//去吧马里奥!把AC公主救回来!
//        ********
//       ************
//       ####....#.
//     #..###.....##....
//     ###.......######
//        ...........
//       ##*#######
//    ####*******######
//   ...#***.****.*###....
//   ....**********##.....
//   ....****    *****....
//     ####        ####
//   ######        ######
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<sstream>
#include<cstring>
#include<vector>
#include<iomanip>
#include<queue>
#include<set>
#define LL long long
#define _64 __int64
const double PI = atan(1.)*4.;
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int a[2000];
    for(int i = 0;i < 2000;i++){
        a[i] = 0;
    }
    int m;
    for(int i = 0;i <n;i++){

        cin >>m;
        a[m]++;
    }
    int manzu = 0;
    int bumanzu = 0;
    int ans = 0;
   for(int i = 0;i < 2000;i++){
        manzu  = manzu + (a[i]-a[i]%2);
        bumanzu = bumanzu + (a[i] % 2);
    }
    ans = manzu + (bumanzu+1) / 2;
    cout << ans << endl;

}

E - Sport Mafia

题意:一个盒,往里面放糖,每次放的糖都是上一次放的+1(也就是等差数列),之后还会吃,问给出操作的次数和最后剩的糖,求吃了多少

做法:因为每次放的都是等差数列,所以可以设变量用数学方法做,如下(计算过程满满一页纸,不放了):

 

//去吧马里奥!把AC公主救回来!
//        ********
//       ************
//       ####....#.
//     #..###.....##....
//     ###.......######
//        ...........
//       ##*#######
//    ####*******######
//   ...#***.****.*###....
//   ....**********##.....
//   ....****    *****....
//     ####        ####
//   ######        ######
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<sstream>
#include<cstring>
#include<vector>
#include<iomanip>
#include<queue>
#include<set>
#define LL long long
#define _64 __int64
const double PI = atan(1.)*4.;
using namespace std;

int main(){
    LL n,k;
    cin >> n >> k;
    LL ans;
    ans = (sqrt(9+8*(k+n))-3)/2;
    ans = n - ans;
    cout << ans << endl;

}

 

 

 

posted @ 2020-10-25 17:24  CCCCrack  阅读(119)  评论(0)    收藏  举报