您的位置:首页 > 其它

ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) 解题报告

2017-02-24 08:50 435 查看
A:A Serial Killer

1 #include <iostream>
2 //#include<bits/stdc++.h>
3 #include <stack>
4 #include <queue>
5 #include <map>
6 #include <set>
7 #include <cstdio>
8 #include <cstring>
9 #include <algorithm>
10 #include <math.h>
11 using namespace std;
12 typedef long long ll;
13 typedef unsigned long long ull;
14 const ll MOD= 1e9+7;
15 ll eu(ll x)
16 {
17     ll t=x;
18     for(ll i=2;i*i<=t;i++)
19     {
20         if(t%i==0)
21             x=x/i*(i-1);
22         while(t%i==0)
23             t/=i;
24     }
25     if(t-1)
26         x=x/t*(t-1);
27     return x;
28 }
29 int main()
30 {
31     ll n,k;
32     cin>>n>>k;
33     while(n>1&&k>0)
34     {
35         if(k%2==1)
36             n=eu(n);
37         k--;
38     }
39     cout<<n%MOD<<"\n";
40 }


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐