QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789522#9622. 有限小数Texcavator#WA 0ms3588kbC++231.4kb2024-11-27 20:40:172024-11-27 20:40:21

Judging History

This is the latest submission verdict.

  • [2024-11-27 20:40:21]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3588kb
  • [2024-11-27 20:40:17]
  • Submitted

answer

#include<iostream>
#include<vector>
#include<cmath>
#define int long long
int a,b;
std::vector<std::pair<int,int> > bm;
std::vector<int> bm2;
int ans=0;
void dfs(int now=0,int mul=1)
{
    if(now==bm.size())
    {
        bm2.push_back(mul);
        return ;
    }
    for(int i=0;i<=bm[now].second;i++)
    {
        dfs(now+1,mul);
        mul*=bm[now].first;
    }
}
int ml[2]={2,5};
void dfs2(int c,int now=0,int mul=1)
{
    if(ans!=0) return ;
    if(now==2)
    {
        for(int i=0;i<bm2.size();i++)
        {
            if((c*bm2[i]+a*mul)%b==0)
            {
                if(b*mul/bm2[i]<=1000000000) 
                {
                    ans=b*mul/bm2[i];
                    return ;
                }
            }
        }
        return ;
    }
    while(mul<=1000000000)
    {
        dfs2(c,now+1,mul);
        if(ans!=0) return ;
        mul*=ml[now];
    }
}
signed main()
{
    std::cin>>a>>b;
    int x=b;
    for(int i=2;i<=sqrt(x);i++)
    {
        if(x%i==0) bm.push_back({i,0});
        while(x%i==0)
        {
            bm[bm.size()-1].second++;
            x/=i;
        }
    }
    if(x!=1) bm.push_back({x,1});
    dfs();
    for(int c=1;c<=b;c++)
    {
        dfs2(c);
        if(ans!=0)
        {
            std::cout<<c<<' '<<ans;
            return 0;
        }
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3588kb

input:

4
1 2
2 3
3 7
19 79

output:

1 1

result:

wrong answer Jury found better answer than participant's 0 < 1 (Testcase 1)