2^x mod n = 1

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14214    Accepted Submission(s):
4403

Problem Description
Give a number n, find the minimum x(x>0) that
satisfies 2^x mod n = 1.
 
Input
One positive integer on each line, the value of
n.
 
Output
If the minimum x exists, print a line with 2^x mod n =
1.

Print 2^? mod n = 1 otherwise.

You should replace x and n with
specific numbers.

 
Sample Input
2
5
 
Sample Output
2^? mod 2 = 1
2^4 mod 5 = 1
 #include <iostream>
using namespace std;
int main()
{
int n,i,j;
while(cin>>n)
{
int x=;
if(n==||n%==)
{
cout<<"2^? mod "<<n<<" = 1\n";
continue;
}
for(i=;;i++)
{
if(x==)
break;
else
{
x=x*;
x=x%n;
}
}
cout<<"2^"<<i+<<" mod "<<n<<" = 1"<<endl;
}
}
 

2^x mod n = 1(hd1395)的更多相关文章

  1. VHDL MOD和REM(转)

    mod(取模)and rem(取余) VHDL has mod and rem. They return the same value if both arguments are positive. ...

  2. 爬虫(六)——存储库(一)MongoDB存储库

    目录 存储库--MongoDB 一.安装MongoDB 4.0 1.安装 2.修改数据库文件和日志保存位置设置(可不改) 3.账户管理.远程服务 三.MongoDB数据库操作 1.对库操作 2.对集合 ...

  3. HDU-1395-2^x mod n = 1(数学题(二次出错))

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1395 这题一定要滴水不漏的把所有代码全部看完. 这个题目是一个数学类型的题,我也没思路,只知道n== ...

  4. 【转】取模(mod)与取余(rem)的区别——Matlab学习笔记

    昨天在学习Matlab的数学函数时,教程中提到取模(mod)与取余(rem)是不同的,今天在网上具体查了一下: 通常取模运算也叫取余运算,它们返回结果都是余数.rem和mod唯一的区别在于:    当 ...

  5. O(n)求素数,求欧拉函数,求莫比乌斯函数,求对mod的逆元,各种求

    筛素数 void shai() { no[1]=true;no[0]=true; for(int i=2;i<=r;i++) { if(!no[i]) p[++p[0]]=i; int j=1, ...

  6. D. Game with modulo 交互题(取余(膜)性质)附带a mod b<a/2证明

    D. Game with modulo 交互题(取余(膜)性质) 题意 猜一个点\(a\)可以向机器提问 点对\((x,y)\) 如果\(x\mod(a)>=y\mod(a)\)回答\(x\) ...

  7. 手把手教你搭饥荒专用服务器(三)—MOD及其他高级设置

    友情链接: 手把手教你搭饥荒专用服务器(一)-服务器准备工作 手把手教你搭饥荒专用服务器(二)-环境配置及基本使用 手把手教你搭饥荒专用服务器(三)-MOD及其他高级设置 手把手教你搭饥荒专用服务器( ...

  8. 我的MYSQL学习心得(六) 函数

    我的MYSQL学习心得(六) 函数 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数据类 ...

  9. 从零开始编写自己的C#框架(17)——Web层后端首页

    后端首页是管理员登陆后进入的第一个页面,主要是显示当前登陆用户信息.在线人数.菜单树列表.相关功能按键和系统介绍.让管理员能更方便的找到息想要的内容. 根据不同系统的需要,首页会显示不同的内容,比如显 ...

随机推荐

  1. python - list, cllections模块的deque对象

    list.count() list.pop()/list.pop(i) list.insert(i,element) list.sort()和sorted(list) list.reverse()和r ...

  2. Scheme 编程环境的设置(racket/petite)-王垠

    Scheme 编程环境的设置 http://www.yinwang.org/blog-cn/2013/04/11/scheme-setup/ sudo apt-get insatll racket ; ...

  3. android gridview布局,实现长按某一个,所有项都显示删除的图标

    最近一直忙着项目开发,有段时间没有写博文了,今天想跟大家分享的是长按gridview中的某一项显示删除图标,此时点击某项便可删除,再长按取消删除图标. gridview的布局文件如下: <?xm ...

  4. grok 正则也支持常规正则

    2016-08-29 17:40:01,19 INFO com.zjzc.common.utils.HttpUtil - 请求接口: https://www.zjcap.cn/pay/interfac ...

  5. Grid++Report支持CS/BS模式的表报插件

    Grid++Report 可用于开发桌面C/S报表与WEB报表(B/S报表),C/S报表开发适用于VB.NET.C#.VB.VC.Delphi等.WEB报表开发适用于ASP.ASP.NET.JSP/J ...

  6. UESTC_Judgment Day CDOJ 11

    Today is the judgment day. The world is ending and all man will pay for their guilt and sin. Now the ...

  7. LeeCode-Remove Duplicates from Sorted List

    Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...

  8. Mod_python: The Long Story

    mod_python: the long story - Grisha Trubetskoy Mod_python: The Long Story Oct 25th, 2013 | Comments ...

  9. PHP MySQL 连接数据库 之 Connect

    连接到一个 MySQL 数据库 在您能够访问并处理数据库中的数据之前,您必须创建到达数据库的连接. 在 PHP 中,这个任务通过 mysql_connect() 函数完成. 语法 mysql_conn ...

  10. Android项目打包开启proguard的混淆优化带来的问题

    1.引入一个sdk以后.打包报错: [INFO] Unexpected error while evaluating instruction: [INFO]   Class       = [com/ ...