QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#132472#6407. Classical A+B Problemcciafrino#Compile Error//C++141.8kb2023-07-30 00:04:122023-07-30 00:04:15

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-30 00:04:15]
  • 评测
  • [2023-07-30 00:04:12]
  • 提交

answer

#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx, avx2")
#include <bits/stdc++.h>

using namespace std;

string sub(const string& s1, const string& s2) {
    int N = int(s1.size());
    string res(s1.size(), '0');
    int emprestimo = 0;
    int last_nn = -1;
    for(int i=0; i<(int)s1.size(); i++) {
        int n1 = s1[s1.size()-1 - i] - emprestimo - '0';
        char aux;
        if(((int) s2.size()) - i > 0) {
            int n2 = s2[((int) s2.size())-1 - i] - '0';
            aux = ((n1-n2 + 10) % 10) + '0';
            emprestimo = (n1-n2) < 0 ? 1 : 0;
            // cout << i << " . " << n1 << " " << n2 << " " << aux << " " << emprestimo << endl;
        } else {
            emprestimo = 0;
            aux = n1 + '0';
            // cout << i << " # " << n1 << " " << aux << " " << emprestimo << endl;
        }
        // cout << last_nn << endl;
        if (aux > '0') last_nn = res.size() - i - 1;
        res[res.size()-1 - i] = aux;
    }
    
    return res.substr(last_nn, N-last_nn);
}

bool check(const string& b) {
    char c = b[b.size()-1];
    for (int i = 0; i < int(b.size())-1; ++i) {
        if (b[i] != c) return false;
    }
    return true;
}

int main() {
    using namespace std;
    cin.tie(nullptr)->sync_with_stdio(false);

    int T; cin >> T;

    while (T--) {
        string S; cin >> S;
        
        bool flag = true;
        for(int i=1; i<=S.size() && flag; i++) {
            for(char c='1'; c<='9' && flag; c++) {
                string a = string(i, c);
                string b = sub(S, a);
                // cout << a << " " << b << " " << S << endl;
                
                if(check(b)){ 
                    cout <<  a << " " << b << '\n';
                    flag = false;
                }
            }
        }
    }

    return 0;
}

Details

cc1plus: error: attribute ‘ avx2’ argument ‘target’ is unknown