HDU 5478 Can you find it

本文概述了AI音视频处理领域的关键技术,包括视频分割、语义识别、自动驾驶、AR、SLAM等,并探讨了其在实际应用中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



Problem Description
Given a prime number C(1C2×105) , and three integers k1, b1, k2 (1k1,k2,b1109) . Please find all pairs (a, b) which satisfied the equation ak1n+b1 + bk2nk2+1 = 0 (mod C)(n = 1, 2, 3, ...).
 

Input
There are multiple test cases (no more than 30). For each test, a single line contains four integers C, k1, b1, k2.
 

Output
First, please output "Case #k: ", k is the number of test case. See sample output for more detail.
Please output all pairs (a, b) in lexicographical order. (1a,b<C) . If there is not a pair (a, b), please output -1.
 

Sample Input
  
23 1 1 2
 

Sample Output
  
Case #1: 1 22
 

Source
 

Recommend
hujie   |   We have carefully selected several similar problems for you:   5493  5492  5491  5490  5489 
 


因为式子对所有的n都满足,我们把n=1和n=2代入.可以推出:a^k1=b^k2。b=c-a^(k1+b1) 。

我们从1到c-1枚举a。再求出b,然后判断a^k1是否等于b^k2即可。


#include<iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long ll;
ll fast(ll a,ll b,ll mod)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
int main()
{
    ll c,k1,b1,k2;
    int Case=0;
    while(cin>>c>>k1>>b1>>k2)
    {
        cout<<"Case #"<<++Case<<":"<<endl;
        ll i;
        int flag=0;
        for(i=1; i<c; i++)
        {
            ll ans=fast(i,k1,c);
            ll ans1=c-fast(i,k1+b1,c);
            ll ans2=fast(ans1,k2,c);
            if(ans==ans2)
            {
                flag=1;
                cout<<i<<" "<<ans1<<endl;
            }
        }
        if(!flag)
            puts("-1");
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值