如何对拍
本人水平有限,题解不到为处,请多多谅解
本蒟蒻谢谢大家观看
对拍程序
__.bat 这是文件名
@echo off
for /L %%i in (1,1,10) do (
echo %%i
Makedata.exe %%i
function.exe
test.exe
fc function.out test.out
if errorlevel 1 goto end
)
:end
pause
点开即可
数据生成
Makedata.cpp
1 #include<iostream> 2 #include<stdlib.h> 3 #include<time.h> 4 inline int random(int x) { 5 return (rand()*RAND_MAX+rand())%x; 6 } 7 inline int random(int l,int r) { 8 return (rand()*RAND_MAX+rand())%(r-l+1)+l; 9 } 10 using namespace std; 11 int main(int argc,char **argv){ 12 freopen("data.in","w",stdout); 13 srand(atoi(argv[1])); 14 // srand(time(0)); 15 //srand(atoi(argv[1])); 16 // char si[]="bbb1.in",so[]="bbb1.out"; 17 //freopen(si,"w",stdout); 18 int q=random(1000); 19 printf("%d\n",q); 20 while(q--){ 21 int x=random(2,100000); 22 printf("%d\n",x); 23 } 24 return 0; 25 }
标程
function.cpp
1 #include<bits/stdc++.h> 2 #pragma GCC optimize(3) 3 4 using namespace std; 5 int q,x,yl; 6 int p[26]; 7 int w[26]={0,3,1,1,5,1,21,1,85,73,341,89,1365,1,5461,4681,21845,1,87381,1,349525,299593,1398101,178481,5592405}; 8 void inint(){ 9 freopen("data.in","r",stdin); 10 freopen("function.out","w",stdout); 11 } 12 inline int read(){ 13 int x=0,f=1;char ch=getchar(); 14 while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();} 15 while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} 16 return x*f; 17 } 18 inline void write(int x) 19 { 20 if(x<0)x=-x,putchar('-'); 21 if(x>9)write(x/10); 22 putchar(x%10+'0'); 23 } 24 void pp(){ 25 p[0]=1; 26 for(int i=1;i<=25;i++){ 27 p[i]=p[i-1]*2; 28 } 29 } 30 void solve1(){ 31 printf("%d\n",w[yl]); 32 return ; 33 } 34 int main() 35 { 36 inint(); 37 pp(); 38 q=read(); 39 while(q--){ 40 x=read(); 41 int wz=0,wzz=0; 42 yl=0; 43 for(int i=1;i<=25;i++){ 44 if(x>p[i]-1&&x<p[i+1]-1){ 45 wz=i; 46 wzz=i+1; 47 printf("%d\n",p[wzz]-1); 48 break; 49 } 50 else if(x==p[i]-1){ 51 yl=i; 52 solve1(); 53 break; 54 } 55 } 56 } 57 return 0; 58 }
暴力程序
test.cpp
1 #include<bits/stdc++.h> 2 #pragma GCC optimize(3) 3 4 using namespace std; 5 int q,k; 6 int x,ans; 7 int temp; 8 void inint(){ 9 freopen("data.in","r",stdin); 10 freopen("test.out","w",stdout); 11 } 12 inline int read(){ 13 int x=0,f=1;char ch=getchar(); 14 while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();} 15 while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} 16 return x*f; 17 } 18 inline void write(int x) 19 { 20 if(x<0)x=-x,putchar('-'); 21 if(x>9)write(x/10); 22 putchar(x%10+'0'); 23 } 24 int main() 25 { 26 inint(); 27 q=read(); 28 while(q--){ 29 x=read(); 30 ans=0,temp=0; 31 for(int i=1;i<x;i++){ 32 temp=__gcd(i^x,i&x); 33 ans=max(ans,temp); 34 } 35 //cout<<"ans= "<<ans<<endl; 36 //cout<<"ans= "<<ans<<endl; 37 printf("%d\n",ans); 38 } 39 40 return 0; 41 }
分别运行即可
如果想要查看某一组具体数据的话:
文件名也是__.bat
@echo off
Makedata.exe 10
pause
点开即可