結果

問題 No.806 木を道に
ユーザー yuruhiya
提出日時 2019-11-10 17:22:45
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 274 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 20,352 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 05:01:51
合計ジャッジ時間 2,020 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%d", &n);
      |     ^~~~~~~~~~~~~~~
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d%d", &x, &y);
      |         ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int n, a[100001], x, y, ans, i;

int main() {
    scanf("%d", &n);
    for(i=0; i<n-1; ++i) {
        scanf("%d%d", &x, &y);
        a[x-1]++; a[y-1]++;
    }
    for(i=0; i<n; i++) {
        if (a[i] > 2)ans += a[i] - 2;
    }
    printf("%d\n", ans);
}
0