2024 暑假友谊赛-热身2

1.G - 🐂🐂🐂🐂🐂🐂🐂🐂

原题链接:

https://vjudge.net/contest/640017#problem/G

由于n/m=x余x,则n=x*(m+1) ,循环累加求解即可

查看代码
 #include<bits/stdc++.h>
#define int long long
const int N=1e6;
using namespace std;
int a[1000000];
signed main()
{
     int n;
     cin>>n;
     int sum=0;
     for(int i=1;i*(i+1)<n;i++)
     {
         if(n%i==0)sum+=(n/i-1);
     }
     cout<<sum;
    return 0;
}

 2.Beautiful Mirrors

原题链接:

https://vjudge.net/problem/CodeForces-1265E/origin

期望dp,求出dp1=1/(𝑝1𝑝2…𝑝𝑖)+1/(𝑝2𝑝3…𝑝𝑖)+⋯+1/后可以递推dpi==pi×dp(i+1)+(1pi)×dp1+1,并且dp(n+1)=0

查看代码
 #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>=b;i--)
ll qp(ll a,ll b,ll p){
    ll ans=1;while(b){
        if(b&1)ans=ans*a%p;
        a=a*a%p;b>>=1;
    }return ans;
}
ll n;ll a[200010],ans,tmp;
const ll mod=998244353;
int main(){
    scanf("%lld",&n);f(i,1,n)scanf("%lld",&a[i]);tmp=1;
    fn(i,n,1){
        tmp=tmp*100%mod*qp(a[i],mod-2,mod)%mod;
        ans=(ans+tmp)%mod;
    }printf("%lld",ans);
    return 0;
}

 

posted @ 2024-07-13 19:24  伊芙加登  阅读(5)  评论(0编辑  收藏  举报