hdu 2502

1083 단어 규칙 을 찾다
http://acm.hdu.edu.cn/showproblem.php?pid=2502 n = 4 시;1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 주의 1 의 개 수 는 앞의 1 에 뒤의 1 을 더 한 것 이기 때문에 공식: ans = 2 ^ (n - 2) * (n - 1) + 2 ^ (n - 1);
#include <iostream>

using namespace std;

int main()
{
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int ans=(n-1)*(1<<(n-2))+(1<<(n-1));
        cout<<ans<<endl;
    }
    return 0;
}

좋은 웹페이지 즐겨찾기