UVa. 112, PKU 1145. Tree Summing. AC
#include int num,yes; char ch; int func(int sum) { int n,leaf=0; if(scanf(" %d",&n)) { sum+=n; scanf(" %c",&ch); leaf+=func(sum); scanf(" %c",&ch); leaf+=func(sum); if(leaf==2 && sum==num) { yes=1; } } else { if(scanf(" %c",&ch)) { if(ch==')') return 1; } } if(scanf(" %c",&ch)) { if(ch==')') return 0; } } main() { while (scanf("%d", &num) != EOF) { scanf(" %c",&ch); func(0); if(yes==1) puts("yes..
더보기
PKU 2636. Electrical Outlets. AC
숏코딩 main(i,j,k,sum){for(scanf("%d",&i);i--;printf("%d\n",sum+1))for(sum=0,scanf("%d",&j);j--;scanf("%d",&k),sum+=k-1);} 정상소스 #include main() { int i, j, k, sum=0; scanf("%d",&i); while(i--) { sum=0; scanf("%d",&j); while(j--) { scanf("%d",&k); if(j) k--; sum+=k; } printf("%d\n",sum); } } Run ID User Problem Result Memory Time Language Code Length Submit Time 4433684 jht009 2636 Accepted 204K 0MS..
더보기