标签:lap mic else ons 简单 ble inline printf closed
这题是真GOU了,改bug改到自闭了。
‘
同样都是预处理,人家加了个素数筛就能过,我没加就疯狂W,W到自闭,其实知道题简单的一批,只需要预处理一下,从n分解到1需要多少次,然后存到数组里就行了,真的是W吐了
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int mod=1e9+7; const int N = 1e6 + 10; bool st[N]; int prime[N]; int cnt; void get_primes() { for(int i = 2; i <= 1000001; i++) { if(!st[i]) prime[cnt ++] = i; for(int j = 0; prime[j] <= 1000001 / i; j ++) { st[prime[j] * i] = true; if(i % prime[j] == 0) break; } } } inline ll mi(ll a,ll b) { ll ans=1; a%=mod; while (b) { if (b&1) ans=ans*a%mod; b>>=1; a=a*a%mod; } return ans; } int A[1000005]= {0,1,1}; int main() { get_primes(); for(int i = 3; i <= 1000000; ++i) { if(st[i]==0) A[i]=1; else { for(int j=2; j<=i; j++) { if(i%j==0) { A[i]=i/j; break; } } } } int t,n,c; scanf("%d",&t); while(t--) { int k=0; scanf("%d%d",&n,&c); while(n!=1) { k++; n=A[n]; } printf("%lld\n",mi(c,k)); } return 0; }
标签:lap mic else ons 简单 ble inline printf closed
原文地址:https://www.cnblogs.com/sszywq/p/13352494.html