社区讨论

难以理解

P3811【模板】模意义下的乘法逆元参与者 3已保存回复 9

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
9 条
当前快照
1 份
快照标识符
@m5kx2rl4
此快照首次捕获于
2025/01/06 18:46
去年
此快照最后确认于
2025/11/04 11:55
4 个月前
查看原帖
这一份代码编译失败
CPP
#include<bits/stdc++.h>
using namespace std;
long long x[3000001] = {0, 1}, n, p;
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> p;
	cout << 1 << endl;
	for (int c = 2; c <= n; c++) {
		x[c] = (p - (p / c)) * x[p % c] % p;
		cout << x[c] << '\n';
	}
	return 0;
}
错误信息:
Nothingiscompiled:OUTPUTexceeds.Nothing is compiled: OUTPUT exceeds.
记录
这一份是满分代码:
CPP
#include<bits/stdc++.h>
using namespace std;
long long x[3000001]={0,1},n,p;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>p;
	cout<<1<<endl;
	for(int c=2;c<=n;c++)
   	{
       	x[c]=p-(p/c)*x[p%c]%p;
		cout<<x[c]<<'\n';
   	}
   return 0;
}
有啥不同???

回复

9 条回复,欢迎继续交流。

正在加载回复...