답안 #667053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
667053 2022-11-30T09:16:38 Z Kalashnikov Nice sequence (IZhO18_sequence) C++17
15 / 100
9 ms 956 KB
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
 
using namespace std;
using ll = long long;
 
const int N = 2e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7 , P = 6547;

void solve(int tc) {
	int n, m;
	cin >> n >> m;
	int coef = 1;
	if(n > m) {
		swap(n , m);
		coef *= -1;
	}
	if(m % n == 0) {
		cout << m-1 << '\n';
		for(int i = 1; i < m; i ++) {
			cout << (-1)*coef << ' ';
		}	
		cout << '\n';
		// return;c
		return;
	}
	int mx = 9e8;
	int psv = mx/(n-1);
	int otr = -psv*(n-1)-1;
	if(m/n == 1) {
		cout << 2*n-1 << '\n';
		for(int i = 1; i < 2*n; i ++) {
			if(i%n == 0) {
				cout << otr*coef << ' ';
			}
			else {
				cout << psv*coef << ' ';
			}
		}
		cout << '\n';
		return;
	}
	cout << m << '\n';
	for(int i = 1; i <= m; i ++) {
		if(i%n == 0) {
			cout << otr*coef << ' ';
		}
		else {
			cout << psv*coef << ' ';
		}
	}
	cout << '\n';
}
/*
3 3 3 -10 3 3
*/
main() {
    ios;
    int tt = 1 , tc = 0;
    cin >> tt;
    while(tt --) {
        solve(++tc);
    }
    return 0;
}

Compilation message

sequence.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   62 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 320 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 1 ms 212 KB Ok
6 Correct 1 ms 212 KB Ok
7 Correct 1 ms 212 KB Ok
8 Correct 1 ms 312 KB Ok
9 Correct 1 ms 316 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 1 ms 320 KB Ok
12 Correct 1 ms 212 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 2 ms 320 KB Ok
7 Correct 8 ms 832 KB Ok
8 Correct 5 ms 468 KB Ok
9 Correct 9 ms 956 KB Ok
10 Correct 6 ms 596 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 316 KB Ok
2 Correct 0 ms 320 KB Ok
3 Correct 0 ms 212 KB Ok
4 Incorrect 1 ms 212 KB Jury has the better answer : jans = 9, pans = 8
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 320 KB Jury has the better answer : jans = 6, pans = 5
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 320 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 1 ms 212 KB Ok
6 Correct 1 ms 212 KB Ok
7 Correct 1 ms 212 KB Ok
8 Correct 1 ms 312 KB Ok
9 Correct 1 ms 316 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 1 ms 320 KB Ok
12 Correct 1 ms 212 KB Ok
13 Correct 0 ms 316 KB Ok
14 Correct 0 ms 320 KB Ok
15 Correct 0 ms 212 KB Ok
16 Incorrect 1 ms 212 KB Jury has the better answer : jans = 9, pans = 8
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 320 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 1 ms 212 KB Ok
6 Correct 1 ms 212 KB Ok
7 Correct 1 ms 212 KB Ok
8 Correct 1 ms 312 KB Ok
9 Correct 1 ms 316 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 1 ms 320 KB Ok
12 Correct 1 ms 212 KB Ok
13 Correct 0 ms 212 KB Ok
14 Correct 0 ms 212 KB Ok
15 Correct 1 ms 212 KB Ok
16 Correct 0 ms 212 KB Ok
17 Correct 0 ms 212 KB Ok
18 Correct 2 ms 320 KB Ok
19 Correct 8 ms 832 KB Ok
20 Correct 5 ms 468 KB Ok
21 Correct 9 ms 956 KB Ok
22 Correct 6 ms 596 KB Ok
23 Correct 0 ms 316 KB Ok
24 Correct 0 ms 320 KB Ok
25 Correct 0 ms 212 KB Ok
26 Incorrect 1 ms 212 KB Jury has the better answer : jans = 9, pans = 8
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 320 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 1 ms 212 KB Ok
6 Correct 1 ms 212 KB Ok
7 Correct 1 ms 212 KB Ok
8 Correct 1 ms 312 KB Ok
9 Correct 1 ms 316 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 1 ms 320 KB Ok
12 Correct 1 ms 212 KB Ok
13 Correct 0 ms 212 KB Ok
14 Correct 0 ms 212 KB Ok
15 Correct 1 ms 212 KB Ok
16 Correct 0 ms 212 KB Ok
17 Correct 0 ms 212 KB Ok
18 Correct 2 ms 320 KB Ok
19 Correct 8 ms 832 KB Ok
20 Correct 5 ms 468 KB Ok
21 Correct 9 ms 956 KB Ok
22 Correct 6 ms 596 KB Ok
23 Correct 0 ms 316 KB Ok
24 Correct 0 ms 320 KB Ok
25 Correct 0 ms 212 KB Ok
26 Incorrect 1 ms 212 KB Jury has the better answer : jans = 9, pans = 8
27 Halted 0 ms 0 KB -