QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#786034#9799. Magical PaletteCodyLee#WA 124ms17108kbC++202.6kb2024-11-26 20:01:362024-11-26 20:01:39

Judging History

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

  • [2024-11-26 20:01:39]
  • 评测
  • 测评结果:WA
  • 用时:124ms
  • 内存:17108kb
  • [2024-11-26 20:01:36]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define dbg(x) cout << #x << " = " << x << "\n";
#define jiasu ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long LL;
typedef pair<LL, LL> PLL;

const LL N = 1e6 + 1;
const LL M = 2020;
const LL mod = 1e9 + 7;

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a * b / gcd(a, b); }

LL qsm(LL a, LL b, LL m)
{
    LL w = 1;
    a %= m;
    while (b)
    {
        if (b & 1) w = (w * a) % m;
        a = a * a % m;
        b >>= 1;
    }
    return w;
}

LL A(LL n, LL m)
{
    LL w = 1;
    while (m--)
    {
        w = w * n;
        n -= 1;
    }
    return w;
}

LL C(LL n, LL m)
{
    LL w = 1;
    m = min(m, n - m);
    for (LL i = 1; i <= m; ++i)
    {
        w = w * (n - m + i) / i;
    }
    return w;
}

LL ol(LL n)
{
    LL w = n;

    for (int i = 2; i <= sqrt(n); ++i)
    {
        if (n % i == 0)
        {
            w = w / i * (i - 1);

            while (n % i == 0) n /= i;
        }
    }

    if (n >= 2) w = w / n * (n - 1);

    return w;
}

LL a[N];
unordered_map<LL, LL> e;
LL w = 0;

LL x[N], y[N];

void solve()
{
    LL n, m;
    cin >> n >> m;
    
    if (n >= m)
    {
    x[1] = 1;
    y[1] = 1;
    for (int i = 2; i <= n; ++i)
    {
        x[i] = a[n + m - i + 1];
    }
    
    for (int i = 2; i <= m; ++i)
    {
        y[i] = a[i];
    }
    }
    else
    {
    x[1] = 1;
    y[1] = 1;
    for (int i = 2; i <= m; ++i)
    {
        y[i] = a[n + m - i + 1];
    }
    
    for (int i = 2; i <= n; ++i)
    {
        x[i] = a[i];
    }        
    }
    
    
    if (e[x[n] * y[m] % (n * m)] != 0)
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
        for (int i = 1; i <= n; ++i)
        {
            cout << x[i] << " ";
        }
        cout << endl;
        for (int i = 1; i <= m; ++i)
        {
            cout << y[i] << " ";
        }
        cout << endl;
    }
    
    
    
}

// abbba

int main()
{
    jiasu;
    
    

    for (int i = 1; i <= 1e6; ++i)
    {
        LL o = 0;
        
        for (int j = 2; j * j <= i; ++j)
        {
            if (i % j == 0)
            {
                o = 1;
                break;
            }
        }
        
        if (!o) 
        {
            //cout << i << endl;
            a[++w] = i;
            e[i] = w;
        }
        
    }

    int t = 1;
    cin >> t;

    while (t--) solve();

    return 0;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 123ms
memory: 10252kb

input:

2
2 3
2 2

output:

Yes
1 2 
1 5 3 
No

result:

ok 2 cases (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 124ms
memory: 17108kb

input:

1
1 1000000

output:

No

result:

wrong answer Wrong Verdict (test case 1)