답안 #1085496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085496 2024-09-08T10:39:13 Z 8pete8 Nice sequence (IZhO18_sequence) C++17
15 / 100
12 ms 1152 KB
#include<stdio.h>
#include <stdlib.h>
#define int long long
int compare(const void* a, const void* b){
   return (*(int*)a - *(int*)b);
}
const int mx=1e9;
void solve(){
    int n,m;scanf("%lld %lld",&n,&m);
    int mul=1;
    if(n>m){
        n^=m,m^=n,n^=m;
        mul=-1;
    }
    int k=m+(n-m%n)-1;
    if(m%n==0){
        printf("%lld\n",m-1);
        for(int i=0;i<m-1;i++)printf("%lld ",-mul);
        printf("\n");
        return;
    }
    int ans[k],val;
    if(n==1)val=0;
    else val=(mx-1)/(n-1);
    printf("%lld\n",k);
    for(int i=0;i<k;i++){
        if((i%n)==(n-1))ans[i]=-mx;
        else ans[i]=val;
    }
    for(int i=0;i<k;i++)printf("%lld ",mul*ans[i]);
    printf("\n");
    
}
int32_t main(){
    int t;scanf("%lld",&t);
    while(t--)solve();
}
/*

+++-

3
3 1
2 3 
1 1

*/

Compilation message

sequence.cpp: In function 'void solve()':
sequence.cpp:9:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     int n,m;scanf("%lld %lld",&n,&m);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~
sequence.cpp: In function 'int32_t main()':
sequence.cpp:35:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     int t;scanf("%lld",&t);
      |           ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 344 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
9 Correct 0 ms 348 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 0 ms 348 KB Ok
12 Correct 1 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 424 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 0 ms 420 KB Ok
4 Correct 1 ms 348 KB Ok
5 Correct 1 ms 348 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 8 ms 928 KB Ok
8 Correct 3 ms 604 KB Ok
9 Correct 12 ms 1152 KB Ok
10 Correct 4 ms 604 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 0 ms 348 KB Ok
4 Incorrect 0 ms 348 KB Jury has the better answer : jans = 9, pans = 8
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Jury has the better answer : jans = 6, pans = 5
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 344 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
9 Correct 0 ms 348 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 0 ms 348 KB Ok
12 Correct 1 ms 348 KB Ok
13 Correct 1 ms 348 KB Ok
14 Correct 0 ms 348 KB Ok
15 Correct 0 ms 348 KB Ok
16 Incorrect 0 ms 348 KB Jury has the better answer : jans = 9, pans = 8
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 344 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
9 Correct 0 ms 348 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 0 ms 348 KB Ok
12 Correct 1 ms 348 KB Ok
13 Correct 0 ms 424 KB Ok
14 Correct 0 ms 348 KB Ok
15 Correct 0 ms 420 KB Ok
16 Correct 1 ms 348 KB Ok
17 Correct 1 ms 348 KB Ok
18 Correct 1 ms 348 KB Ok
19 Correct 8 ms 928 KB Ok
20 Correct 3 ms 604 KB Ok
21 Correct 12 ms 1152 KB Ok
22 Correct 4 ms 604 KB Ok
23 Correct 1 ms 348 KB Ok
24 Correct 0 ms 348 KB Ok
25 Correct 0 ms 348 KB Ok
26 Incorrect 0 ms 348 KB Jury has the better answer : jans = 9, pans = 8
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 344 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
9 Correct 0 ms 348 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 0 ms 348 KB Ok
12 Correct 1 ms 348 KB Ok
13 Correct 0 ms 424 KB Ok
14 Correct 0 ms 348 KB Ok
15 Correct 0 ms 420 KB Ok
16 Correct 1 ms 348 KB Ok
17 Correct 1 ms 348 KB Ok
18 Correct 1 ms 348 KB Ok
19 Correct 8 ms 928 KB Ok
20 Correct 3 ms 604 KB Ok
21 Correct 12 ms 1152 KB Ok
22 Correct 4 ms 604 KB Ok
23 Correct 1 ms 348 KB Ok
24 Correct 0 ms 348 KB Ok
25 Correct 0 ms 348 KB Ok
26 Incorrect 0 ms 348 KB Jury has the better answer : jans = 9, pans = 8
27 Halted 0 ms 0 KB -