26.8.16

· · 个人记录

声明

代码仅供参考,请勿抄袭!

题目信息

题目名称 难度 思路(没有/有一点/有) 分数
T806457 T2 入门 有 0
T806459 T4 普及− 有 0
T806462 T6 入门 有 80
T806463 T7 普及− 有 0

题目详细

T2

#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 2e8+5;
int a[N];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int m;
        cin >> m;
        a[m]++;
    }
    for (int i = 1; i <= 2e8; i++){
        if (a[i] % 2 == 1){
            cout << i;
            return 0;
        }
    }
    return 0;
}
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
map<int, int>tong;//用map做桶
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int a;
        cin >> a;//输入
        tong[a]++;//将桶的第a个加一
    }
    for (auto i:tong){//for循环遍历map,记住要用auto
        if (i.second % 2 == 1){//判断次数是否为奇数
            cout << i.first;//如果是,则输出它的值
            return 0;//直接结束程序
        }
    }
    return 0;
}
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
struct st{
    string s;
    int t = 0;
}a[100005];
int cmp(st a1, st b1){
    return a1.t < b1.t;
}
map<string, int>q;
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int p;
    for (int i = 1; i <= n; i++){
        cin >> a[i].s >> p;
        a[i].t += p;
        q[a[i].s]++;
    }
    sort(a+1, a+n+1, cmp);
    for (int i = 1; i <= n; i++){
        if (q[a[i].s] == 1){
            cout << a[i].s << " ";
        }
        else{
            q[a[i].s]--;
        }
    }
    return 0;
}
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
map<string, int>m1;//存数据,当桶
map<int, string>m2;//存歌手名字
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int b;
        string a;
        cin >> a >> b;
        m1[a] += b;//将桶的第a位歌手加上分数b
    }
    for (auto i : m1){//for循环遍历map1
        m2[i.second] = i.first;//将map2的这个值设为map1的下标(歌手名)
    }
    for (auto i : m2){//for循环遍历map2
        cout << i.second << " ";//输出歌手名
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int a[10000005];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int b;
    cin >> b;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int sum = 0;
    for (int i = 1; i <= n; i++){
        if (a[i] - a[i - 1] == b){
            sum++;
        } 
    }
    cout << sum;
    return 0;
}
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int a[10000005];
map<int, int>ma;//拿map当桶
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, c;
    cin >> n >> c;//输入
    for (int i = 1; i <= n; i++){
        cin >> a[i];//输入
        int b = a[i] - c;//定义b,用来存a[i]-c
        ma[b]++;//将map的第b个加一,表示这一个出现了一次
    }
    int ans = 0;//最终答案
    for(int i = 1; i <= n; i++){
        ans += ma[a[i]];//最终答案加上map[a[i]](a)
    }
    cout << ans;//输出
    return 0;
}