灵异事件!!!
#include <iostream>
#include <climits>
using namespace std;
int cube(int i)
{
int count=0;
int check;
while(i>0)
{
check+=i%2;
count++;
i/=2;
}
if(check==1) return count-1;
else return -1;
}
int main()
{
int number;
while(!cin.eof())
{
cin >> number;
int a,b;
a=b=INT_MAX;
if(number==1)
{
cout << "2^? mod 1 = 1" <<endl;
continue;
}
if(number%2==0)
{
cout << "2^? mod "<< number <<" = 1" <<endl;
continue;
}
else
{
int i;
int temp;
for(i=1;i<INT_MAX;i++)
{
temp=cube(i*number+1);
//cout << temp << "\t"; //灵异行
if(temp>0)
{
cout <<"2^" << temp<< " mod "<<number<<" = 1" << endl;
break;
}
}
if(i==INT_MAX)
cout << "2^? mod "<<number<<" = 1" <<endl;
}
}
return 0;
}
如果把上面的注释行取消注释,则结果正确.比如输入5,输出应为:2^4 mod 5 = 1;
可如果注释掉,输入5后,就是2^? mod 2 = 1了.
高手赐教.
#include <climits>
using namespace std;
int cube(int i)
{
int count=0;
int check;
while(i>0)
{
check+=i%2;
count++;
i/=2;
}
if(check==1) return count-1;
else return -1;
}
int main()
{
int number;
while(!cin.eof())
{
cin >> number;
int a,b;
a=b=INT_MAX;
if(number==1)
{
cout << "2^? mod 1 = 1" <<endl;
continue;
}
if(number%2==0)
{
cout << "2^? mod "<< number <<" = 1" <<endl;
continue;
}
else
{
int i;
int temp;
for(i=1;i<INT_MAX;i++)
{
temp=cube(i*number+1);
//cout << temp << "\t"; //灵异行
if(temp>0)
{
cout <<"2^" << temp<< " mod "<<number<<" = 1" << endl;
break;
}
}
if(i==INT_MAX)
cout << "2^? mod "<<number<<" = 1" <<endl;
}
}
return 0;
}
如果把上面的注释行取消注释,则结果正确.比如输入5,输出应为:2^4 mod 5 = 1;
可如果注释掉,输入5后,就是2^? mod 2 = 1了.
高手赐教.
...全文
相关推荐
做一个恐怖、灵异的资讯类APP
【标题】:“做一个恐怖、灵异的资讯类APP”在这个标题中,我们关注的是开发一个以恐怖和灵异为主题的资讯应用程序。
灵异相机 GhostCam v1.9.4
灵异相机 GhostCam v1.9.4版本:1.9.4软件语言:非中文软件类别:特效相机软件大小:8.23 MB适用固件:2.1及更高固件内置广告:有广告适用平台:Android一款相机拍照软件,用
rails 常见灵异错误汇总
不断学习和实践,将使你更加熟练地驾驭Rails,减少这些“灵异”错误的出现。
做Oracle数据库迁移,碰上了灵异的字符集问题,懵了
这个就是那个出现灵异现象的test.dmp文件博文链接:https://rainbamboo.iteye.com/blog/215343
帝国CMS仿五十一区灵异奇闻异事猎奇未解之谜网站模板.txt
帝国CMS仿五十一区灵异奇闻异事猎奇未解之谜网站模板.txt


