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;
		}
	}
}


全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 11:16
点赞 评论 收藏
分享
后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务