SDNU 1102.小树林(水题)

Description

LG家门口有一片小树林,在小树林中央有一块写有相关说明的标牌,其中关于树木数量的部分是这么写的:
“……这片树林中的树木可构成a个以这块标牌为圆心的同心圆,其中最靠近这块标牌的圆上有b棵树,其他圆上树木数量都是向内一层的圆上树木数量的c倍。……”
试求LG家门口这片小树林有多少树木。

Input

一行,三个正整数 a b c

Output

一行,计算结果,保证不会太大(不需要用高精度)

Sample Input

63 1 2

Sample Output

9223372036854775807

Source

Unknown
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
using namespace std;

#define ll long long

unsigned ll a, b, c;//如果不行,就改为ll
unsigned ll sum = 0, s= 0;

 unsigned ll qsm(unsigned ll x, unsigned ll y)
 {
     unsigned ll ans = 1;
     while(y)
     {
         if(y&1)ans = ans*x;
         y /= 2;
         x *= x;
     }
     return ans;
 }

 int main()
 {
     scanf("%llu%llu%llu", &a, &b, &c);
     sum = qsm(c, a);
     sum = (sum-1)*b/(c-1);
     printf("%llu\n", sum);
     return 0;
 }

 

转载于:https://www.cnblogs.com/RootVount/p/10946648.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值