UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#212809#3827. Awangliwen123456039ms1196kbC++1.2kb2024-10-20 11:41:012024-10-20 12:45:18

answer

#include <bits/stdc++.h>
using namespace std;

int countGoodPairs(int n) {
	n<=5000;
    int count = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            int sum_binary_i = 0, sum_ternary_i = 0;
            int sum_binary_j = 0, sum_ternary_j = 0;
            int temp_i = i, temp_j = j;
            while (temp_i > 0) {
                sum_binary_i += temp_i % 2;
                temp_i /= 2;
            }
            while (temp_j > 0) {
                sum_binary_j += temp_j % 2;
                temp_j /= 2;
            }
            temp_i = i;
            temp_j = j;
            while (temp_i > 0) {
                sum_ternary_i += temp_i % 3;
                temp_i /= 3;
            }
            while (temp_j > 0) {
                sum_ternary_j += temp_j % 3;
                temp_j /= 3;
            }
            if (sum_binary_i + sum_binary_j < 10 && sum_ternary_i + sum_ternary_j < 10) {
                count++;
            }
        }
    }
    return count;
}

int main() {
    int n;
    cin >> n;
    cout << countGoodPairs(n) << endl;
    cout<<4;
    cout<<16;
    return 0;
}

Details

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

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1196kb

input:

2

output:

4
416

result:

wrong answer 1st numbers differ - expected: '0', found: '4'

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 1196kb

input:

92

output:

6445
416

result:

wrong answer 1st numbers differ - expected: '348', found: '6445'

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 39ms
memory: 1196kb

input:

939

output:

98195
416

result:

wrong answer 1st numbers differ - expected: '7730', found: '98195'

Subtask #4:

score: 0
Time Limit Exceeded

Test #7:

score: 0
Time Limit Exceeded

input:

4375

output:


result: