#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 5000000000000000000LL
ll mod=1000000007LL;
template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}
template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}
class Matrix
{
public:
ll a,b,c,d;
Matrix() {a=1LL; b=0LL; c=0LL; d=1LL;}
Matrix(ll x, ll y, ll w, ll z) {a=x; b=y; c=w; d=z;}
Matrix operator *(Matrix X)
{
Matrix ANS(a*X.a+b*X.c,a*X.b+b*X.d,c*X.a+d*X.c,c*X.b+d*X.d);
ANS.a%=mod; ANS.b%=mod; ANS.c%=mod; ANS.d%=mod;
return ANS;
}
};
Matrix fastexp(Matrix A, ll e)
{
if(e==0LL) {Matrix id; return id;}
if(e%2LL==0LL) {Matrix V = fastexp(A,e/2LL); return (V*V);}
else {Matrix V=fastexp(A,e/2LL); return (V*V*A);}
}
ll fastexp(ll a, ll e)
{
if(e==0LL) {return 1LL;}
if(e%2LL==0LL) {ll val = fastexp(a,e/2LL); return ((val*val)%mod);}
else {ll val=fastexp(a,e/2LL); return ((((val*val)%mod)*a)%mod);}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll N,U; cin>>N>>U;
vector<vector<ll> > adj; vector<ll> xx; REP(i,0,N) {adj.pb(xx);}
pl cur;
REP(i,0,N-1)
{
cin>>cur.ff>>cur.ss; cur.ff--; cur.ss--;
adj[cur.ff].pb(cur.ss);
adj[cur.ss].pb(cur.ff);
}
if(N==2) {ll ans = 4LL*fastexp(4LL,U-1LL); ans%=mod; if(ans<0) {ans+=mod;} cout<<ans<<endl;}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |