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