3626: 程序对拍

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:0 解决:0

题目描述

P7909 [CSP-J 2021] 分糖果


https://www.luogu.com.cn/problem/P7909?contestId=136435



baoli.cpp
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+10;

signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n,l,r,ans=0;
	cin>>n>>l>>r;
	for(int i=l;i<=r;i++){
		ans=max(ans,i%n);
	}
	cout<<ans;
	return 0;
}

/*

*/

std.cpp
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+10;

signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n,l,r;
	cin>>n>>l>>r;
	if(l/n<r/n) cout<<n-1;
	else cout<<r%n;
	return 0;
}

/*

*/
data.cpp


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+10;
mt19937_64 x(time(0)^clock()^ *new char);
inline int randint(int l,int r) {
	return x()%(r-l+1)+l;
}
signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	// freopen("./Downloads/code/data.in","w",stdout);
	int n=randint(1,1e9);
	int l=randint(1,1e9/2);
	int r=randint(l+1,1e9);

	cout<<n<<' '<<l<<' '<<r<<'\n';
	return 0;
}

/*
/Users/hanxu/Downloads/code
1. rand() 生成随机数,但每次运行都一样
2. srand() 随机种子,以时间作为运行介质
   time(0) 每秒变化一次
3. srand(time(0)^(unsigned long long) new char);
   但是数字较小
4. rand()<<16LL | rand()  构造较大的数字
   但没有区间设定
5. x%(r-l+1)+l   设置[l,r]区间数字

link: https://zhuanlan.zhihu.com/p/600683484
	  https://www.luogu.com/article/e9gx9tx2	
0. mt19937产生的随机数值域大,周期长,耗时短(约是rand()的1/3时间)
1. mt19937_64 x(110); //以110作为随机种子,固定不变
2. mt19937_64 x(time(0)); //以时间作为随机种子
3. 值域为:unsigned int, 即0~2^32-1

#include<cstdio>
#include<cstdlib>
#include<ctime>
*/

duipai.cpp


#include<bits/stdc++.h>
#include<cstdio>
#include<ctime>
#include<unistd.h>
#include<sys/time.h>
using namespace std;
#define int long long
const int N=1e6+10;

signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n=100,cnt=0;
	
	for(int i=1;i<=n;i++){
		system("./Downloads/code/data > data.in");
		system("./Downloads/code/baoli<data.in>baoli.out");
		system("./Downloads/code/std<data.in>std.out");
		if(system("diff std.out baoli.out")){
			cout<<"WA\n";
			break;
		}else{
			cout<<"测试点 "<<i<<" OK\n";
		}
	}
	cout<<"对拍结束";
	return 0;
}

/*

*/