Meaning of the questions:
Set F (n, m) is larger than n, and m-th prime number n, given a k = (f (n, m) -n) xor n and m, find the smallest n
answer:
For a given m, the a k around n legitimate distribution very dense, so violent k neighborhood search.
#include<iostream> #define LL long long using namespace std; LL gcd(LL a,LL b){ return b==0?a:gcd(b,a%b); } bool solve(LL n,LL k,int m){ //找到n后面的第m个互质 register LL i; for(i=n+1;;i++){ if(gcd(i,n)==1)m--; if(m==0)break; } if(((i-n)^n)==k){ // printf("%lld",i); return 1; } else return 0; } int main(){ int t; scanf("%d",&t); while(t--){ LL k; int m; scanf("%lld %d",&k,&m); for(register LL i=max(1ll,k-3000);i<=k+3000;i++){ if(solve(i,k,m)){ printf("%lld\n",i); goto A; } } printf("-1\n"); A:; } }