一个奇怪的错误
查看原帖
一个奇怪的错误
575994
Hisaishi_Kanade楼主2022/4/23 13:04

100分:

#include <stdio.h>
#include <iostream>
using namespace std;
int _x;char _c;
int read(){
	_x=0;_c=getchar();
	while(_c<'0'||_c>'9')_c=getchar();
	while(_c<='9'&&_c>='0'){
		_x=(_x<<1)+(_x<<3)+(_c^'0');
		_c=getchar();
	}
	return(_x);
}
int n,p;
int inv[3000005]={0,1};
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	puts("1");
	ios::sync_with_stdio(false);
	n=read();p=read();
	for(int i=2;i<=n;i++){
		inv[i]=(long long)(p-p/i)*inv[p%i]%p;
		cout<<inv[i]<<'\n';
	}
	return(0);
}

0分:

#include <stdio.h>
#include <iostream>
using namespace std;
int _x;char _c;
int read(){
	_x=0;_c=getchar();
	while(_c<'0'||_c>'9')_c=getchar();
	while(_c<='9'&&_c>='0'){
		_x=(_x<<1)+(_x<<3)+(_c^'0');
		_c=getchar();
	}
	return(_x);
}
int n,p;
int inv[3000005]={0,1};
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	puts("1");
	n=read();p=read();
	for(int i=2;i<=n;i++){
		inv[i]=(long long)(p-p/i)*inv[p%i]%p;
		cout<<inv[i]<<'\n';
	}
	return(0);
}

然鹅两个代码只有puts("1");的位置不同,应该影响不了结果。

更诡异的事是本机都过了。

2022/4/23 13:04
加载中...