UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212671#3827. Atommy1002020ms2012kbC++1.7kb2024-10-20 09:16:102024-10-20 12:36:16

answer

#include <bits/stdc++.h>

using namespace std;
int n;
const int N = 5005;
int tw[N][20], tr[N][20];
int cnt1[N], cnt2[N];
void weiw(int x) {
    int ll = x;
    while(x) {
        tw[ll][++cnt1[ll]] = x % 2;
        x /= 2;
    }
    // printf("\n\n");
    return;
}
void weir(int x) {
    int ll = x;
    while(x) {
        tr[ll][++cnt2[ll]] = x % 3;
        x /= 3;
    }
    return;
}
int dao[N];
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        weiw(i), weir(i);
        // for(int k = 1; k <= cnt1[i]; k++) dao[k] = tw[i][k];
        // for(int k = cnt1[i]; k >= 1; k--) tw[i][k] = dao[cnt1[i] - k + 1];
        // for(int k = 1; k <= cnt2[i]; k++) dao[k] = tr[i][k];
        // for(int k = cnt1[i]; k >= 1; k--) tr[i][k] = dao[cnt2[i] - k + 1];
    }
    // for(int i = 1; i <= n; i++) {
    //     printf("%d %d %d\n", i, cnt1[i], cnt2[i]);
    //     for(int k = 1; k <= cnt1[i]; k++) printf("%d", tw[i][k]);
    //     printf("\n");
    //     for(int k = 1; k <= cnt2[i]; k++) printf("%d", tr[i][k]);
    //     printf("\n");printf("\n");
    // }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            int flag = 0;
            for(int k = 1; k <= min(cnt1[i], cnt1[j]); k++) {
                if(tw[i][k] == 1 && tw[j][k] == 1) {
                    flag = 1;
                    break;
                }
            }
            for(int k = 1; k <= min(cnt2[i], cnt2[j]); k++) {
                if(tr[i][k] + tr[j][k] >= 3) {
                    flag = 1;
                    break;
                }
            }
            if(!flag) ans++;
        }
    }
    printf("%d\n", ans);
}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 1204kb

input:

2

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 1208kb

input:

8

output:

6

result:

ok 1 number(s): "6"

Subtask #2:

score: 20
Accepted

Test #3:

score: 20
Accepted
time: 0ms
memory: 1228kb

input:

92

output:

348

result:

ok 1 number(s): "348"

Test #4:

score: 0
Accepted
time: 0ms
memory: 1224kb

input:

85

output:

316

result:

ok 1 number(s): "316"

Subtask #3:

score: 20
Accepted

Test #5:

score: 20
Accepted
time: 15ms
memory: 1364kb

input:

939

output:

7730

result:

ok 1 number(s): "7730"

Test #6:

score: 0
Accepted
time: 17ms
memory: 1368kb

input:

994

output:

7994

result:

ok 1 number(s): "7994"

Subtask #4:

score: 50
Accepted

Test #7:

score: 50
Accepted
time: 300ms
memory: 1924kb

input:

4375

output:

58626

result:

ok 1 number(s): "58626"

Test #8:

score: 0
Accepted
time: 312ms
memory: 1956kb

input:

4594

output:

66410

result:

ok 1 number(s): "66410"

Test #9:

score: 0
Accepted
time: 432ms
memory: 2012kb

input:

4989

output:

74836

result:

ok 1 number(s): "74836"

Test #10:

score: 0
Accepted
time: 487ms
memory: 2000kb

input:

4877

output:

73756

result:

ok 1 number(s): "73756"

Test #11:

score: 0
Accepted
time: 457ms
memory: 1992kb

input:

4790

output:

72308

result:

ok 1 number(s): "72308"

Extra Test:

score: 0
Extra Test Passed