Pupu

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 21   Accepted Submission(s) : 6

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

There is an island called PiLiPaLa.In the island there is a wild animal living in it, and you can call them PuPu. PuPu is a kind of special animal, infant PuPus play under the sunshine, and adult PuPus hunt near the seaside. They fell happy every day.

But there is a question, when does an infant PuPu become an adult PuPu?
Aha, we already said, PuPu is a special animal. There are several skins wraping PuPu's body, and PuPu's skins are special also, they have two states, clarity and opacity. The opacity skin will become clarity skin if it absorbs sunlight a whole day, and sunshine can pass through the clarity skin and shine the inside skin; The clarity skin will become opacity, if it absorbs sunlight a whole day, and opacity skin will keep sunshine out.

when an infant PuPu was born, all of its skins were opacity, and since the day that all of a PuPu's skins has been changed from opacity to clarity, PuPu is an adult PuPu.

For example, a PuPu who has only 3 skins will become an adult PuPu after it born 5 days(What a pity! The little guy will sustain the pressure from life only 5 days old)

Now give you the number of skins belongs to a new-laid PuPu, tell me how many days later it will become an adult PuPu?

Input

There are many testcase, each testcase only contains one integer N, the number of skins, process until N equals 0

Output

Maybe an infant PuPu with 20 skins need a million days to become an adult PuPu, so you should output the result mod N

Sample Input

2
3
0

Sample Output

1
2

思路:容易得出公式(pow(2,n-1)+1)%n;然后是快速幂取模。。。
AC代码:
#include <cstdio>using namespace std;long long pow_mod(long long a,long long b,long long m)
{long long t=1;while(b){if(b&1) t=t*a%m;a=a*a%m;b>>=1;}return t;
}
int main()
{int n;while(scanf("%d",&n)!=EOF,n){long long res=0;res=(pow_mod(2,n-1,n)+1)%n;printf("%lld\n",res);}return 0;
}

HDU 3003 Pupu相关推荐

  1. HDU - 3003 - Pupu(快速幂)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3003; 题目大意: 有一种生物,这种生物有N层外壳,每一层壳每经过一天太阳照射会由透明变成不透明,或 ...

  2. HDU 3003 PuPu(N非常大 语死早)

    坑点: when an infant PuPu was born, all of its skins were opacity, and since the day that all of a PuP ...

  3. 快速幂取模——Pupu(HDU 3003)

    题目: 由题目推出计算公式: ans = (2^(n-1) + 1) % n 因为n取值很大,所以需要用到快速幂取模: int multi(int a,int b) { int ret; ret=1; ...

  4. hdu 3003-Pupu-快速幂取模

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3003 Pupu Time Limit: 2000/1000 MS (Java/Others)     ...

  5. hdu_3003Pupu(快速幂)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3003 Pupu Time Limit: 2000/1000 MS (Java/Others)    M ...

  6. HDU——1106排序(istringstream的使用、STLvector练习)

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submiss ...

  7. hdu 5438 Ponds 拓扑排序

    Ponds Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/contests/contest_showproblem ...

  8. HDU 1248 寒冰王座(全然背包:入门题)

    HDU 1248 寒冰王座(全然背包:入门题) http://acm.hdu.edu.cn/showproblem.php?pid=1248 题意: 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票 ...

  9. hdu 1312 Red and Black 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312 第二条深搜,题目并不难,但是做了我好久好久,由于一个细节,让我赌上了一个晚上的时间. 题目大意: ...

最新文章

  1. 20w7珠led驱动电源电路图_三种常用的LED驱动电源电路图详解!
  2. mysql 从库 速度太慢_mysql查询速度慢的原因[整理版]
  3. Asterisk AGI脚本
  4. 总结JSON.parse()报错VM71:1 Uncaught SyntaxError: Unexpected token u in JSON at position 0等之类的问题
  5. shell脚本发邮件内容html,Shell发送邮件以HTML展示
  6. [BZOJ3684]大朋友和多叉树
  7. 有关编辑距离计算的一点整理。
  8. matlab 系统 h10,Thinkbook、ThinkPad出厂带H10混合固态的机器重装系统启用傲腾的方法...
  9. 2021年高压电工考试及高压电工考试资料
  10. 机电传动控制 第三周作业
  11. crm系统需要的服务器,灵当CRM管理系统运行环境-CRM服务器配置
  12. 技术人员的等级划分和资质要求
  13. java 软件流程图使用什么_流程图怎么画,教你正确使用流程图模板
  14. 计算机101页报告翻译,冯诺伊曼 101页报告 First Draft of a Report on the EDVAC
  15. 《视频理解中的神经网络结构设计》讲座笔记 作者:邱钊凡
  16. 7-2 动物爱吃什么?
  17. 如何使用计算机勾绘汇水面积,汇水面积怎么计算
  18. php msvcr110,msvcr110.dll丢失的解决方法是什么
  19. iframe父页面子页面相互调用方法
  20. 360随身WiFi在没有网络的情况下打开热点

热门文章

  1. 微型计算机的显卡,来一份白色的信仰,ROG-STRIX-RTX3080-O10G-WHITE显卡深度评测
  2. [jQuery]黑马课程学习笔记(一篇完)
  3. vue3学习5:v-for
  4. windows cmd 打开相对路径下的网页文件
  5. JS判断身份证(15位18位)的合法性
  6. 公共供水管网漏损治理智能化管理系统解决方案
  7. 零中频接收机频率转换图_复数RF混频器零中频架构及高级算法:下一代SDR收发器中的黑魔法...
  8. 建立数据驱动的人力资源管理:以红海云eHR系统为例
  9. 算法手撕代码111~120
  10. JAVA毕设项目个性化推荐的扬州农业文化旅游管理平台(java+VUE+Mybatis+Maven+Mysql)