问题 I: Common Knowledge

时间限制: 1 Sec  内存限制: 64 MB
提交: 9  解决: 8
[提交][状态][讨论版]

题目描述

Alice and Bob play some game in which they score points. Each of the two has an n-digit scoreboard which depicts numbers in base 10 (with leading zeroes). The digits 0 to 9 are displayed on a seven-segment display in the following fashion:


For some odd reason, the two players cannot see the scoreboards entirely. Alice can only see the lower half of her own scoreboard and the upper half of Bob’s scoreboard. Bob can only see the upper half of his scoreboard and the upper half of Alice’s scoreboard. Here, ‘half’ is meant to
include the horizontal segments in the digits’ centers: they can be seen by both players at all times. For example, if one sees the upper half of an eight, one can conclude that the digit is not a zero.


A pair of n-digit scores is called fully known if both players know both scores (i.e. all 2n digits) by looking at the displays with their restricted vision. The players cannot communicate.

输入

The input consists of:
• one line with an integer n (1 ≤ n ≤ 20), where n is the number of digits.

输出

Output the number of score pairs that can be displayed on two n-digit scoreboards and are fully known by both players.

样例输入

10

样例输出

1073741824
#include <iostream>
#include <cstdio>
#include <algorithm>using namespace std;int main()
{int x=8;long long int mi;int n;while(scanf("%d",&n)!=EOF){mi=x;if(n==0){printf("1\n");continue;}for(int i=1;i<n;){if(i<n/2){mi*=mi;i*=2;}else{mi*=x;i+=1;}}printf("%lld\n",mi);mi=0;}return 0;
}

转载于:https://www.cnblogs.com/TWS-YIFEI/p/5940256.html

Common Knowledge_快速幂相关推荐

  1. 数学--数论--HDU 4675 GCD of Sequence(莫比乌斯反演+卢卡斯定理求组合数+乘法逆元+快速幂取模)

    先放知识点: 莫比乌斯反演 卢卡斯定理求组合数 乘法逆元 快速幂取模 GCD of Sequence Alice is playing a game with Bob. Alice shows N i ...

  2. `Computer-Algorithm` 数论基础知识 (同余,取模,快速幂,质数,互质,约数,质因子)

    catalog 同余 取模 快速幂 质数 互质 约数 质因子 @Delimiter(旧解释) 经验谈 两数之差也整除 加一的特殊性 取模 累加的周期性 取模的唯一集合 取模下的四则运算 除法的不可约性 ...

  3. c语言的幂乘积表达式,POJ 1845 Sumdiv [素数分解 快速幂取模 二分求和等比数列]

    大致题意: 求A^B的所有约数(即因子)之和,并对其取模 9901再输出. 解题基础: 1) 整数的唯一分解定理: 任意正整数都有且只有一种方式写出其素因子的乘积表达式. ,其中 为素数 2) 约数和 ...

  4. 矩阵快速幂+构造方法

    与快速幂一样,可以将递推式通过二进制的方式来进行优化,这个学了快速幂就是十分容易理解 大概的板子如下: struct mat///自己定义大小的矩阵 {ll m[11][11]; }; mat mul ...

  5. 【做题】SRM701 Div1 Hard - FibonacciStringSum——数学和式&矩阵快速幂

    原文链接 https://www.cnblogs.com/cly-none/p/SRM701Div1C.html 题意:定义"Fibonacci string"为没有连续1的01串 ...

  6. 快速幂 + 矩阵快速幂

    快速幂 1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #define LL lo ...

  7. BZOJ1965 [Ahoi2005]SHUFFLE 洗牌 快速幂

    欢迎访问~原文出处--博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1965 题意概括 对于扑克牌的一次洗牌是这样定义的,将一叠N(N为偶数)张扑克牌平均分成上下两叠,取 ...

  8. 牛客网练习赛44-B(快速幂+模拟)

    题目链接:https://ac.nowcoder.com/acm/contest/548/B 题意:计算m/n小数点后k1位到k2位,1≤m≤n≤109,1<=k1<=k2<=109 ...

  9. 【ACM】杭电OJ 4704 Sum (隔板原理+组合数求和公式+费马小定理+快速幂)

    http://acm.hdu.edu.cn/showproblem.php?pid=4704 1.隔板原理 1~N有N个元素,每个元素代表一个1.分成K个数,即在(N-1)个空挡里放置(K-1)块隔板 ...

最新文章

  1. CentOS Linux 新建oracle数据库实例并连接
  2. 设计模式-结构型-适配器
  3. 计算机应用基础二00018,2019年10月自学考试00018《计算机应用基础》试题(二)
  4. 551. Student Attendance Record I 从字符串判断学生考勤
  5. 高地址和低地址、高字节低字节、大小端模式的转换,存储顺序
  6. python json串中文乱码问题
  7. 数据上报java_通过Jaeger上报Java应用数据
  8. asp.net mvc项目中遇到的古怪的问题,(项目中有frame框架)
  9. Idea(二) 解决IDEA卡顿问题及相关基本配置
  10. SVN上库前检查(钩子程序)
  11. linux进入根目录的代码,Linux根目录+源代码目录
  12. 玲珑学院-1014-Absolute Defeat【思维】
  13. Android 获取设备SN号
  14. 关于Vmware中的Ubuntu不断弹窗Num Lock的问题
  15. Firefox书签同步工具Xmarks
  16. 3D Food Printing【3D食物打印】
  17. AI换脸在电竞圈火了!大司马PDD大秀肌肉辣舞
  18. 怎样才能画好人物手臂?画好人物手臂有哪些技巧?
  19. 小程序开发--地区选择四级联动(选择省,市,县,镇)
  20. Boosting算法与假设间隔

热门文章

  1. (五)Struts2 标签
  2. python实现: protobuf解释器
  3. Abiword页面布局
  4. 简单小程序代码_小程序该如何运营
  5. e3是合法浮点数吗_下列哪些是不合法的浮点数的选项是 123 2e4.2 .e5 -e3 .234 1e3
  6. linq 清除一条数据中的某个字段值_B端通用批量数据导入方案设计
  7. java remove(index)_方法removeElementAt(int index)在Java中做什么?
  8. bind1st bind2nd的使用
  9. java 中的override overload 比较
  10. vue项目封装axios请求