疾风亦有归途


私信TA

用户名:uq_75623990602

访问量:3329

签 名:

等  级
排  名 9581
经  验 1085
参赛次数 0
文章发表 8
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

解题思路:
快速幂,费马小定理,递推式
注意事项:
数据类型,先转换为long long与long long的数运算,最后转换为int,而不是int 与long long运算再换为int。
参考代码:

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>//strlen、strcmp 
#include <cmath>
#include <cstdlib>//malloc
#include <algorithm>
using namespace std;


#define maxn 100010
int mod =  998244353;
int x[maxn],y[maxn];
long long quickpow(long long a,int n){
	long long s = 1;
	while(n){
		if(n&1)
			s = s*a%mod;
		a = (a*a)%mod;
		n = n>>1;
	}
	return s;
}
int main() {
	int n;
	long long one = 1;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%d%d",&x[i],&y[i]);
	}
	int ans=0,pre=1;
	for(int i = 1;i <= n;i++){
		pre = one*pre * y[n-i+1] % mod 
		* quickpow(y[n-i+1]-x[n-i+1],mod-2)%mod;
		ans = (one*ans + pre)%mod; 
	}
	printf("%d\n",ans);
		
	return 0;
}


 

0.0分

12 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区