URAL 1385 Interesting Number

Description

Tyomitch calls the number with 2  N digits (without leading zeroes) "interesting", if it's divisible by both the number formed from its first N digits and the number formed from its last  N digits. For example, 1020 is "interesting" (divisible by 10 and 20) and 2005 is not. Tyomitch wants to know how many "interesting" 2  N-digit numbers exist. You are to help him.

Input

Input contains an integer  N (1 ≤  N ≤ 10000).

Output

Output the number of "interesting" 2  N-digit numbers.

Sample Input

input output
1
14

Notes

11, 12, 15, 22, 24, 33, 36, 44, 48, 55, 66, 77, 88, 99.


脑洞题。。打表可以看出来大致的规律。

还有一种方法 

把这个数写成 a*10^n+b,则满足条件等价于b%a=0 and a*10^n%b=0,令 b=ka,则10^n%c=0。且a和b都是n位数。

当 n==1 c可为 1 2 5;当 n==2 c可为 1 2 4 5;n>=3 c可为1 2 4 5 8.

当a为n位数时,要控制a的范围保证b也是n位数。显然,n==1 ans=14,n==2 ans=155

n>=3时,令 a = 10^(n+1)

则(a/8-a/10)*5+(a/5-a/8)*4+(a/4-a/5)*3+(a/2-a/4)*2+(a-a/2)*5=63/40*(10^n)


#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int n;
int main()
{

    while(~scanf("%d",&n))
    {
        if(n==1) cout<<14<<endl;
        else if(n==2) cout<<155<<endl;
        else
        {
            cout<<1575;
            for(int i=0;i<n-3;i++)
            cout<<0;
            cout<<endl;
        }
    }
    return 0;
}








  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值