Common Knowledge_快速幂

问题 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值