N题求助。。。
N题,判断为奇数时,我打表成满足2^k+1的质数不行么。
当n为奇数的时候,如果n与2^k + 1互质, n*(2^k)会多1个质数2,而 n*(2^k + 1) 会多一个质数(2^k + 1)。。。感觉没毛病(难道是我读错题了么?) 用例通过率为 66.67%
#include<bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long ll a[7]={0,3,5,17,257,65537}; int main(){ int t; ll temp; cin >> t; while(t--){ cin >> temp; if( temp & 1){ int i = 1; while(gcd(temp, a[i])==a[i]) i++; cout << temp*(a[i]-1) << " " << temp*a[i]<<endl; } else{ cout << temp <<" " << temp <<endl; } } }