您的位置:首页 > 大数据 > 人工智能

2017 Multi-University Training Contest - Team 3 1008 RXD and math

2017-08-01 20:35 561 查看

RXD and math

[align=center]Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 261    Accepted Submission(s): 134
[/align]

[align=left]Problem Description[/align]

RXD is a good mathematician.

One day he wants to calculate:

∑i=1nkμ2(i)×⌊nki−−−√⌋

output the answer module 109+7.
1≤n,k≤1018

μ(n)=1(n=1)

μ(n)=(−1)k(n=p1p2…pk)

μ(n)=0(otherwise)

p1,p2,p3…pk
are different prime numbers

 

[align=left]Input[/align]

There are several test cases, please keep reading until EOF.

There are exact 10000 cases.

For each test case, there are 2 numbers n,k.
 

[align=left]Output[/align]

For each test case, output "Case #x: y", which means the test case number and the answer.
 

[align=left]Sample Input[/align]

10 10

 

[align=left]Sample Output[/align]

Case #1: 999999937

 

直接暴力打表,发现是n^k,快速幂直接水过

///AC代码
/* ***********************************************
┆  ┏┓   ┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃       ┃ ┆
┆┃   ━   ┃ ┆
┆┃ ┳┛ ┗┳ ┃ ┆
┆┃       ┃ ┆
┆┃   ┻   ┃ ┆
┆┗━┓ 马 ┏━┛ ┆
┆  ┃ 勒 ┃  ┆      
┆  ┃ 戈 ┗━━━┓ ┆
┆  ┃ 壁     ┣┓┆
┆  ┃ 的草泥马  ┏┛┆
┆  ┗┓┓┏━┳┓┏┛ ┆
┆   ┃┫┫ ┃┫┫ ┆
┆   ┗┻┛ ┗┻┛ ┆
************************************************ */
#include <iostream>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <bitset>
#include <string>
#include <vector>
#include <iomanip>
#include <cstring>
#include <algorithm>
#include <functional>
#define PI acos(-1)
#define eps 1e-8
#define inf 0x3f3f3f3f
#define debug(x) cout<<"---"<<x<<"---"<<endl
typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;

long long pow(long long a, long long n)
{
long long text = 1;
while (n)
{
if (n & 1)
{
text = (text % mod) * (a % mod) % mod;
}
a = (a % mod) * (a % mod) % mod;
n >>= 1;
}
return text;
}
int main()
{
long long n, k;
int i = 1;
while (~scanf("%lld%lld", &n, &k))
{
long long text = pow(n, k);
printf("Case #%d: %lld\n", i++, text);
}
return 0;
}

/************************************************
┆  ┏┓   ┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃       ┃ ┆
┆┃   ━   ┃ ┆
┆┃ ┳┛ ┗┳ ┃ ┆
┆┃       ┃ ┆
┆┃   ┻   ┃ ┆
┆┗━┓    ┏━┛ ┆
┆  ┃    ┃  ┆      
┆  ┃    ┗━━━┓ ┆
┆  ┃  AC代马   ┣┓┆
┆  ┃           ┏┛┆
┆  ┗┓┓┏━┳┓┏┛ ┆
┆   ┃┫┫ ┃┫┫ ┆
┆   ┗┻┛ ┗┻┛ ┆
************************************************ */
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐