对拍

以前缀和为例
1.正解:

#include<stdio.h>
using namespace std;
long long a[10010];
int main(){
	freopen("data.txt","r",stdin);
	freopen("A+B.txt","w",stdout);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=10000;i++){
		a[i]=a[i-1]+i;
	}
	for (int i=1;i<=n;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d\n",a[r]-a[l-1]);
	}
	return 0;
}

2.暴力:

#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	freopen("data.txt","r",stdin);
	freopen("hhboy.txt","w",stdout);
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		int ans=0;
		for (int j=l;j<=r;j++) ans+=j;
		printf("%d\n",ans);
	}
	return 0;
}

3.数据:

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<time.h>
using namespace std;
int main(){
	freopen("data.txt","w",stdout);
	int n=rand()%10000+1;
	printf("%d\n",n);
	for (int i=1;i<=n;i++){
		int l=rand()%10000+1;
		int r=rand()%10000+1;
		printf("%d %d\n",l,r);
	}
	return 0;
}

4.对拍:

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<time.h>
#include<queue>
#include<windows.h>
using namespace std;
int long long read(){
	long long x=0;
	bool f=1;
	char c=getchar();
	while (c<'0'||c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main(){
	for (int i=1;i<=100;i++){
		system("datamaker.exe>data.txt");
		system("A+B.exe<data.txt>A+B.txt");
		double st=clock();
		system("hhboy.exe<data.txt>hhboy.txt");
		double ed=clock();
		if (system("fc A+B.txt hhboy.txt")==true){
			printf("WA\n");
			break;
		}
		else{
			printf("AC #%d Time:%.3lfms\n",i,ed-st);
		}
	}
	return 0;
} 

5.模板:

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<time.h>
#include<queue>
#include<windows.h>
using namespace std;
int long long read(){
	long long x=0;
	bool f=1;
	char c=getchar();
	while (c<'0'||c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main(){
	for (int i=1;i<=100;i++){
		system("数据.exe");
		system("正解.exe");
		double st=clock();
		system("暴力.exe");
		double ed=clock();
		if (system("fc 正解.out 暴力.out")==true){
			printf("WA\n");
			break;
		}
		else{
			printf("AC #%d Time:%.3lfms\n",i,ed-st);
		}
	}
	return 0;
} 
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值