結果

問題 No.3412 Christmas Tree Coloring
コンテスト
ユーザー wym
提出日時 2025-12-19 17:01:22
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 455 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,677 ms
コンパイル使用メモリ 162,712 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-12-19 17:01:28
合計ジャッジ時間 4,597 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll=long long;

const int N=2e5, mod=998244353;

ll fpow(ll b, ll p)
{
  ll ret=1;
  while(p)
  {
    if(p&1)
      ret = ret * b % mod;
    b=b*b%mod;
    p/=2;
  }
  return ret;
}

int a[N];
int main()
{
  int n;
  cin>>n;
  for(int i=0, x, y; i<n-1; i++)
  {
    cin >> x >> y;
    a[x]++, a[y]++;
  }
  
  ll ans=0;
  for(int i=1; i<=n; i++)
    ans = (ans + fpow(2, a[i]))%mod;
  cout << ans;
    
}
0