---
# System prepended metadata

title: 2023 / 05 / 05 新北資研歡樂社內賽解答

---

# 2023 / 05 / 05 新北資研歡樂社內賽解答

### pA. 小寶的四則運算
```c++
#include <bits/stdc++.h>
#define whitebear ios_base::sync_with_stdio(0), cin.tie(0) , cout.tie(0)
#define vi vector<int>
#define vii vector<vector<int>>
#define pii pair<int,int>
#define f first
#define s second
using namespace std;

signed main(){
    long long a = 0, b = 0;
    char c = '\0';
    while(cin >> a >> c >> b){
        if(c == '+'){
            cout << a + b << "\n";
        }else if(c == '-'){
            cout << a - b << "\n";
        }else if(c == '*'){
            cout << a * b << "\n";
        }else{
            cout << a / b << "\n";
        }
        c = '\0';
    }
    return 0;
}
```
---
### pB. 貓貓的英文筆記
```c++
#include <bits/stdc++.h>
#define whitebear ios_base::sync_with_stdio(0), cin.tie(0) , cout.tie(0)
#define vi vector<int>
#define vii vector<vector<int>>
#define pii pair<int,int>
#define f first
#define s second
using namespace std;

signed main(){
    whitebear;
    int N = 0;
    cin >> N;
    vector<string> dict(N,"");
    string input;
    for(int i = 0;i < N + 1 ;i++){
        getline(cin,input);
        if(i != 0) dict[i - 1] = input;
    }
    sort(dict.begin() , dict.end());
    for(int i = 0;i < N ;i++){
        cout << dict[i] << "\n";
    }
    return 0;
}
```
---
### pC. 電神的編輯器
```c++
#include <bits/stdc++.h>
#define whitebear ios_base::sync_with_stdio(0), cin.tie(0) , cout.tie(0)
#define vi vector<int>
#define vii vector<vector<int>>
#define pii pair<int,int>
#define f first
#define s second
using namespace std;

signed main(){
    whitebear;
    int n = 0, q= 0;
    cin >> n >> q;
    cin.ignore();
    vector<vector<char>> note(n,vector(99999,'\0'));
    string clipboard = "";
    string temp = "";
    for(int i = 0;i < n;i++){
        getline(cin,temp);
        for(int k = 0;k < temp.length();k++){
            note[i][k] = temp[k];
        }
    }
    int times = 0;
    while(times < q){
        string contrl = "";
        int i = 0, l = 0, r = 0, p = 0;
        cin >> contrl;
        if(contrl == "cut"){
            clipboard = "";
            cin >> i >> l >> r;
            for(int k = l;k <=r;k++){
                clipboard += note[i][k];
            }
            note[i].erase(note[i].begin()+l,note[i].begin()+(r+1));
        }else{
            cin >> i >> p;
            int clip = clipboard.length(),cnt = 0,element_cnt = 0;
            while(note[i][element_cnt] != '\0'){
                element_cnt++;
            }
            if(p == (element_cnt+1)){
                while(clip != 0){
                    note[i].push_back(clipboard[cnt]);
                    clip--;
                    cnt++;
                    p++;
                }
            }else {
                while (clip != 0) {
                    note[i].insert(note[i].begin() + p, clipboard[cnt]);
                    clip--;
                    cnt++;
                    p++;
                }
            }
        }
        times++;
    }
    int next = 0;
    for(int i = 0;i < n;i++){
        while(note[i][next] != '\0'){
            cout << note[i][next];
            next++;
        }
        cout << "\n";
        next = 0;
    }
    return 0;
}
```
---
### pD. 摳營的數學專題
```c++
#include <bits/stdc++.h>
#define whitebear ios_base::sync_with_stdio(0), cin.tie(0) , cout.tie(0)
#define vi vector<int>
#define vii vector<vector<int>>
#define pii pair<int,int>
#define f first
#define s second
using namespace std;

signed main(){
    whitebear;
    long long a = 0, b = 0, c = 0;
    cin >> a >> b >> c;
    cout << 1 << "\n";
    return 0;
}
```
---
### pE. 一定是簽到題的啦
```c++
#include <bits/stdc++.h>
#define whitebear ios_base::sync_with_stdio(0), cin.tie(0) , cout.tie(0)
#define vi vector<int>
#define vii vector<vector<int>>
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define f first
#define s second
using namespace std;

const double ouob = 1.35;

bool compare(piii a , piii b){
    return a.s < b.s;
}

signed main(){
    whitebear;
    int N = 0;
    cin >> N;
    piii dxy[N];
    for(int i = 0;i < N;i++){
        cin >> dxy[i].f.f >> dxy[i].f.s >> dxy[i].s;
    }
    sort(dxy,dxy+N, compare);
    for(int i = 0;i < N;i = i + 2){
        int t1 = dxy[i].f.f * dxy[i+1].f.s;
        int t2 = dxy[i].f.s * dxy[i+1].f.f;
        cout << fixed << setprecision(2) << (t1 - t2) * ouob <<"\n";
    }
    return 0;
}
```
---
### pF. 拖更的匿名板
```c++
#include <bits/stdc++.h>
#define whitebear ios_base::sync_with_stdio(0), cin.tie(0) , cout.tie(0)
#define vi vector<int>
#define vii vector<vector<int>>
#define pii pair<int,int>
#define f first
#define s second
using namespace std;

const int week = 7;

bool compare(pii a , pii b){
    return a.s > b.s;
}

signed main(){
    whitebear;
    int N = 0 , day = 0;
    cin >> N;
    int ptr = 1;
    while(ptr <= N){
        pii gm[week];
        int total = 0 , max = 0;
        cin >> max;
        for(int i = 0;i < week;i++) cin >> gm[i].f >> gm[i].s;
        sort(gm,gm + week,compare);
        int backup = 0;
        for(int i = 0;i < week ;i++){
            backup = max;
            if(backup - gm[i].f >= 0){
                total += gm[i].s;
                max -= gm[i].f;
            }else{
                continue;
            }
        }
        cout << "Week #" << ptr << ": " << total <<"\n";
        ptr++;
    }
    return 0;
}
```
---
