QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#72030#2007. 格雷码Cyh29hao100 ✓2ms3780kbC++14595b2023-01-13 18:31:332023-01-13 18:31:37

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-13 18:31:37]
  • Judged
  • Verdict: 100
  • Time: 2ms
  • Memory: 3780kb
  • [2023-01-13 18:31:33]
  • Submitted

answer

#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
const int mx=65;
int n;ll k;
int ans[mx],cnt=0;
ll pow2[mx];
//9223372036854775808
//                 *2
//18446744073709551616
int main()
{
    scanf("%d%llu",&n,&k);
    pow2[0]=1;for(int i=1;i<n;++i)pow2[i]=pow2[i-1]*2;
    //printf("%llu\n",pow2[63]);
    while(k)
    {
        if(k>=pow2[n-cnt-1]){
            k=pow2[n-cnt-1]-k-1+pow2[n-cnt-1];
            ans[cnt]=1;
        }
        cnt++;
    }
    
    for(int i=0;i<n;++i)printf("%d",ans[i]);
    printf("\n");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 2ms
memory: 3588kb

input:

2 2

output:

11

result:

ok "11"

Test #2:

score: 5
Accepted
time: 2ms
memory: 3608kb

input:

3 3

output:

010

result:

ok "010"

Test #3:

score: 5
Accepted
time: 2ms
memory: 3776kb

input:

4 10

output:

1111

result:

ok "1111"

Test #4:

score: 5
Accepted
time: 2ms
memory: 3484kb

input:

5 14

output:

01001

result:

ok "01001"

Test #5:

score: 5
Accepted
time: 1ms
memory: 3584kb

input:

6 33

output:

110001

result:

ok "110001"

Test #6:

score: 5
Accepted
time: 0ms
memory: 3532kb

input:

6 60

output:

100010

result:

ok "100010"

Test #7:

score: 5
Accepted
time: 2ms
memory: 3612kb

input:

9 500

output:

100001110

result:

ok "100001110"

Test #8:

score: 5
Accepted
time: 2ms
memory: 3532kb

input:

10 1000

output:

1000011100

result:

ok "1000011100"

Test #9:

score: 5
Accepted
time: 1ms
memory: 3568kb

input:

10 1023

output:

1000000000

result:

ok "1000000000"

Test #10:

score: 5
Accepted
time: 2ms
memory: 3532kb

input:

10 0

output:

0000000000

result:

ok "0000000000"

Test #11:

score: 5
Accepted
time: 2ms
memory: 3484kb

input:

32 123456

output:

00000000000000010001001101100000

result:

ok "00000000000000010001001101100000"

Test #12:

score: 5
Accepted
time: 2ms
memory: 3616kb

input:

63 2019000

output:

000000000000000000000000000000000000000000100011010100111100100

result:

ok "000000000000000000000000000000000000000000100011010100111100100"

Test #13:

score: 5
Accepted
time: 2ms
memory: 3600kb

input:

32 54321

output:

00000000000000001011111000101001

result:

ok "00000000000000001011111000101001"

Test #14:

score: 5
Accepted
time: 2ms
memory: 3476kb

input:

60 910200

output:

000000000000000000000000000000000000000010110001001011000100

result:

ok "000000000000000000000000000000000000000010110001001011000100"

Test #15:

score: 5
Accepted
time: 2ms
memory: 3780kb

input:

63 123321

output:

000000000000000000000000000000000000000000000010001000101100101

result:

ok "000000000000000000000000000000000000000000000010001000101100101"

Test #16:

score: 5
Accepted
time: 1ms
memory: 3584kb

input:

63 5000000

output:

000000000000000000000000000000000000000011010100110111011100000

result:

ok "000000000000000000000000000000000000000011010100110111011100000"

Test #17:

score: 5
Accepted
time: 1ms
memory: 3604kb

input:

63 998244353353442899

output:

000101100110111010001010000101011111000111111100001010101111010

result:

ok "000101100110111010001010000101011111000111111100001010101111010"

Test #18:

score: 5
Accepted
time: 0ms
memory: 3540kb

input:

63 9223372036854775807

output:

100000000000000000000000000000000000000000000000000000000000000

result:

ok "100000000000000000000000000000000000000000000000000000000000000"

Test #19:

score: 5
Accepted
time: 2ms
memory: 3532kb

input:

44 4444444444444

output:

01100000111110101011010011000110010010010010

result:

ok "01100000111110101011010011000110010010010010"

Test #20:

score: 5
Accepted
time: 2ms
memory: 3772kb

input:

64 18446744073709551615

output:

1000000000000000000000000000000000000000000000000000000000000000

result:

ok "1000000000000000000000000000000000000000000000000000000000000000"

Extra Test:

score: 0
Extra Test Passed