QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#188395#1095. Brilliant Sequence of UmbrellasAs3b_team_f_masr#WA 23ms7536kbC++14884b2023-09-25 19:52:082023-09-25 19:52:09

Judging History

你现在查看的是最新测评结果

  • [2023-09-25 19:52:09]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:7536kb
  • [2023-09-25 19:52:08]
  • 提交

answer


#include <bits/stdc++.h>

typedef long double ld;
typedef long long ll;
using namespace std;
int di[] = {1, 0, -1, 0, 0, 1, -1, 1};
int dj[] = {0, 1, 0, -1, -1, 0, 1, -1};

const ll oo = 1e18;
const int N = 1e6 + 5, M = 1e4 + 5, MOD = 1e9 + 7;
#define EPS 1e-9

ll n, q, a[N];
bool p[N];
vector<int>primes;
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //memset(dp, -1, sizeof dp);
    ll n;
    cin>>n;

    vector<ll>ans;
    ans.push_back(1);
    int lst=1;
    for(int i=1;i<N;i++)
    {

        if(1ll*i*(i+1)>n)break;
        if(i>=2&&__gcd(i+1,lst)!=1)
        {
            if(1ll*i*(i+2)>n)break;
            ans.push_back(1ll*i*(i+2));
            i++;
        }
        else ans.push_back(1ll*i*(i+1));
        lst=i;
    }
    cout<<ans.size()<<'\n';
    for(auto x:ans)cout<<x<<" ";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3588kb

input:

10

output:

3
1 2 6 

result:

ok OK.

Test #2:

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

input:

22

output:

4
1 2 6 15 

result:

ok OK.

Test #3:

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

input:

2

output:

2
1 2 

result:

ok OK.

Test #4:

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

input:

14

output:

3
1 2 6 

result:

ok OK.

Test #5:

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

input:

15

output:

4
1 2 6 15 

result:

ok OK.

Test #6:

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

input:

16

output:

4
1 2 6 15 

result:

ok OK.

Test #7:

score: -100
Wrong Answer
time: 23ms
memory: 7536kb

input:

999999999999

output:

500002
1 2 6 15 35 63 99 143 195 255 323 399 483 575 675 783 899 1023 1155 1295 1443 1599 1763 1935 2115 2303 2499 2703 2915 3135 3363 3599 3843 4095 4355 4623 4899 5183 5475 5775 6083 6399 6723 7055 7395 7743 8099 8463 8835 9215 9603 9999 10403 10815 11235 11663 12099 12543 12995 13455 13923 14399 ...

result:

wrong answer Integer 500002 violates the range [666667, 1000000]