답안 #1032790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032790 2024-07-24T08:43:35 Z vjudge1 Party (INOI20_party) C++17
7 / 100
510 ms 604 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int N = 201, mod = 1e9+7;

int q, n, ans, dis[N], cnt[N];

int pw(int x, int y) {
  return (!y ? 1 : pw(x*x % mod, y >> 1) * (y & 1 ? x : 1) % mod);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> n;
    
    ans = 0;
    for (int i = 1; i <= n; i++) {
      memset(dis, -1, sizeof(dis));
      memset(cnt, 0, sizeof(cnt));

      queue<pair<int, int>> q;
      q.push(make_pair(0, i));
      while (!q.empty()) {
        int d = q.front().first;
        int x = q.front().second;
        q.pop();

        if (dis[x] != -1) continue;
        dis[x] = d;
        cnt[d]++;

        if (x/2 >= 1 && dis[x/2] == -1) q.push(make_pair(d+1, x/2));
        if (x*2 <= n && dis[x*2] == -1) q.push(make_pair(d+1, x*2));
        if (x*2 + 1 <= n && dis[x*2 + 1] == -1) q.push(make_pair(d+1, x*2 + 1));
      }

      for (int j = n-1; j > 0; j--) {
        ans += j * ((pw(2, cnt[j]) - 1 + mod) % mod) % mod * pw(2, cnt[j+1]) % mod;
        ans %= mod;
        
        cnt[j] += cnt[j+1];
        cnt[j] % mod;
      }
    }

    cout << ans * pw((pw(2, n) - 1 + mod) % mod, mod-2) % mod << "\n";
  }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:47:16: warning: statement has no effect [-Wunused-value]
   47 |         cnt[j] % mod;
      |         ~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 8 ms 348 KB Output is correct
3 Correct 8 ms 348 KB Output is correct
4 Correct 8 ms 348 KB Output is correct
5 Correct 11 ms 460 KB Output is correct
6 Correct 9 ms 348 KB Output is correct
7 Correct 10 ms 348 KB Output is correct
8 Correct 12 ms 460 KB Output is correct
9 Correct 10 ms 344 KB Output is correct
10 Correct 12 ms 348 KB Output is correct
11 Correct 510 ms 452 KB Output is correct
12 Correct 476 ms 348 KB Output is correct
13 Correct 462 ms 344 KB Output is correct
14 Correct 489 ms 464 KB Output is correct
15 Correct 474 ms 460 KB Output is correct
16 Correct 494 ms 456 KB Output is correct
17 Correct 289 ms 344 KB Output is correct
18 Correct 288 ms 468 KB Output is correct
19 Correct 287 ms 456 KB Output is correct
20 Correct 300 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 8 ms 348 KB Output is correct
3 Correct 8 ms 348 KB Output is correct
4 Correct 8 ms 348 KB Output is correct
5 Correct 11 ms 460 KB Output is correct
6 Correct 9 ms 348 KB Output is correct
7 Correct 10 ms 348 KB Output is correct
8 Correct 12 ms 460 KB Output is correct
9 Correct 10 ms 344 KB Output is correct
10 Correct 12 ms 348 KB Output is correct
11 Correct 510 ms 452 KB Output is correct
12 Correct 476 ms 348 KB Output is correct
13 Correct 462 ms 344 KB Output is correct
14 Correct 489 ms 464 KB Output is correct
15 Correct 474 ms 460 KB Output is correct
16 Correct 494 ms 456 KB Output is correct
17 Correct 289 ms 344 KB Output is correct
18 Correct 288 ms 468 KB Output is correct
19 Correct 287 ms 456 KB Output is correct
20 Correct 300 ms 344 KB Output is correct
21 Runtime error 1 ms 604 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -