답안 #688621

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
688621 2023-01-27T21:07:42 Z inwbear Lutrija (COCI19_lutrija) C++14
0 / 70
1 ms 300 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<LL>ans;
LL a,b;
bool isprime(LL x){
  if(x<2)return false;
  LL k=sqrt(x);
  for(int i=2;i<=k&&i<x;i++){
    if(x%k==0)return false;
  }
  return true;
}
bool to2(LL x,bool rev){
  if(x==2){
    if(rev)ans.push_back(2);
    return true;
  }
  bool p=false;
  LL rr=x;
  while(1){
    if(!isprime(rr))break;
    if(isprime(rr-2)){
      p=true;
      break;
    }
    rr=rr+2;
  }
  if(p){
    if(rev){
      for(LL i=x;i<=rr;i+=2)ans.push_back(i);
      ans.push_back(2);
    }
    else for(LL i=rr;i>=x;i-=2)ans.push_back(i);
  }
  else{
    rr=x;
    while(1){
      if(!isprime(rr))break;
      if(isprime(rr-2)){
        p=true;
        break;
      }
      rr=rr-2;
    }
    if(p){
      if(rev){
        for(LL i=x;i>=rr;i-=2)ans.push_back(i);
        ans.push_back(2);
      }
      else for(LL i=rr;i<=x;i+=2)ans.push_back(i);
    }
  }
  return p;
}
int main(){
  scanf("%lld %lld",&a,&b);
  if(to2(a,true)&&to2(b,false)){
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++)printf("%d ",ans[i]);
  }
  else printf("-1");
}

Compilation message

lutrija.cpp: In function 'int main()':
lutrija.cpp:59:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   59 |     printf("%d\n",ans.size());
      |             ~^    ~~~~~~~~~~
      |              |            |
      |              int          std::vector<long long int>::size_type {aka long unsigned int}
      |             %ld
lutrija.cpp:60:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for(int i=0;i<ans.size();i++)printf("%d ",ans[i]);
      |                 ~^~~~~~~~~~~
lutrija.cpp:60:43: warning: format '%d' expects argument of type 'int', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} [-Wformat=]
   60 |     for(int i=0;i<ans.size();i++)printf("%d ",ans[i]);
      |                                          ~^
      |                                           |
      |                                           int
      |                                          %lld
lutrija.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |   scanf("%lld %lld",&a,&b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Integer parameter [name=arr[3]] equals to -2039078213, violates the range [1, 1000000000000000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Integer parameter [name=arr[1]] equals to -2145466189, violates the range [1, 1000000000000000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Integer parameter [name=arr[3]] equals to -2070243849, violates the range [1, 1000000000000000]
2 Halted 0 ms 0 KB -