QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#408717#5103. Fair DivisionberarchegasWA 1ms3512kbC++141.3kb2024-05-10 21:51:312024-05-10 21:51:33

Judging History

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

  • [2024-05-10 21:51:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3512kb
  • [2024-05-10 21:51:31]
  • 提交

answer

#include <bits/stdc++.h>
#define O_O
using namespace std;
using ll = long long;
#define int ll
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ff first
#define ss second
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());
    
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;
const int INF = 1e9;

int n, m;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>> n>> m;

    vector<__int128> vec{1};
    for(int a=2;; a++)
    {
        bool passou = false;
        __int128 pa = 1;
        for(int i=0; i<n; i++)
        {
            pa *= a;
            if(pa - vec.back() > m)
            {
                passou = true;
                break;
            } 
        }
        if(passou)
            break;
        // cout<< a<< " "<< (long long)pa<< endl;
        vec.push_back(pa);
    }
    for(int i=0; i<vec.size(); i++)
    {
        for(int j=i-1; j>=0; j--)
        {
            __int128 qn = vec[i], qmpn = vec[j];
            int q = i+1;
            int qmp = j+1;
            int p = q - qmp;
            if(__gcd(p, q) == 1 && ((__int128)m * p) % (qn - qmpn) == 0)
            {
                cout<< p<< " "<< q<< "\n";
                return 0;
            }
        }
    }
    cout<< "impossible\n";

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3512kb

input:

13 382475111752106101

output:

impossible

result:

wrong answer 1st lines differ - expected: '17 28', found: 'impossible'