QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#836255#1095. Brilliant Sequence of UmbrellasASnownWA 32ms9220kbC++171.3kb2024-12-28 17:40:182024-12-28 17:40:19

Judging History

This is the latest submission verdict.

  • [2024-12-28 17:40:19]
  • Judged
  • Verdict: WA
  • Time: 32ms
  • Memory: 9220kb
  • [2024-12-28 17:40:18]
  • Submitted

answer

#include<bits/stdc++.h>
#define file(F) freopen(#F".in","r",stdin),freopen(#F".out","w",stdout)
#define lowbit(x) ((x)&-(x))
#define ALL(x) (x).begin(),(x).end()
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define popc(x) (__builtin_popcountll((x)))
#define abs(x) ((x)>=0?(x):-(x))
using namespace std;
using ll=long long;
using uint=uint32_t;
namespace asnown {
using i32=int32_t; using u32=uint32_t;
using i64=int64_t; using u64=uint64_t;
using i128=__int128_t; using u128=__uint128_t; };
template<typename T>
inline bool Max(T &x,T y) { return std::less<T>()(x,y)&&(x=y,true); }
template<typename T>
inline bool Min(T &x,T y) { return std::less<T>()(y,x)&&(x=y,true); }
void Solve();
ll gcd(ll a,ll b) {
   if(b) while(b^=a^=b^=a%=b);
   return a;
}
signed main() {
#ifndef ONLINE_JUDGE
#endif
   cin.tie(nullptr)->sync_with_stdio(false);
   Solve();
}
void Solve() {
   ll n; cin>>n;
   if(n==1) return void(puts("1\n1"));
   vector<ll> ans{1,2};
   ll lst=2;
   for(ll i=2;;)
      if(gcd(i+1,lst)!=1) {
         if(i*(i+2)>n) break;
         ans.emplace_back(i*(i+2));
         i+=2;
      } else {
         if(i*(i+1)>n) break;
         ans.emplace_back(i*(i+1));
         i++;
      }
   printf("%d\n",(int)ans.size());
   for(auto x:ans) printf("%d ",x); puts("");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10

output:

3
1 2 6 

result:

ok OK.

Test #2:

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

input:

22

output:

4
1 2 6 15 

result:

ok OK.

Test #3:

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

input:

2

output:

2
1 2 

result:

ok OK.

Test #4:

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

input:

14

output:

3
1 2 6 

result:

ok OK.

Test #5:

score: 0
Accepted
time: 1ms
memory: 4020kb

input:

15

output:

4
1 2 6 15 

result:

ok OK.

Test #6:

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

input:

16

output:

4
1 2 6 15 

result:

ok OK.

Test #7:

score: -100
Wrong Answer
time: 32ms
memory: 9220kb

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]