qz! #6 TLE
查看原帖
qz! #6 TLE
764672
ZJLmath楼主2023/1/14 12:52
#include<iostream>
using namespace std;
#define int long long
int a,b,x,y;
inline void Myfunc(int a,int b){
	if(b==0){
		x=1,y=0;
		return;
	}
	Myfunc(b,a%b);
	int tmp=x;
	x=y;
	y=tmp-a/b*y;
}
inline int read(){
	int ret=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=!f;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		ret*=10;
		ret+=ch-'0';
		ch=getchar();
	}
	return ret*f;
}
inline void write(int x){
	if(x>9)write(x/10);
	putchar(x%10^48); 
}
signed main(){
	ios::sync_with_stdio(0);
	int n,p;
	n=read();
	p=read();
	for(int i=1;i<=n;++i){
		Myfunc(i,p);
		write((x%p+p)%p);
		putchar('\n');
	}
}
2023/1/14 12:52
加载中...