Submission #862625

# Submission time Handle Problem Language Result Execution time Memory
862625 2023-10-18T16:29:34 Z AOrdinary Nadan (COCI18_nadan) C++14
10 / 50
1 ms 604 KB
#include<bits/stdc++.h>
#define ld long double
#define ss second
#define ff first
#define int long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define ll long long
#define rall(x) x.rbegin(), x.rend()
#define sz(a) (int)a.size()
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define sp(x) fixed << setprecision(x)
#define ms multiset
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y);
#define mll map<ll,ll> 
using namespace std;
const string YES = "YES";
const string NO = "NO";
const long long MOD = 1e9 + 7;
const int N = 1e5 + 5;
const long long inf = 9e18;
const int M = 3e3 + 5;
const double EPS = 1e-6;
const ll neg = -1;
const string imp = "impossible";

	
void setIO(string name = "") {
    if (sz(name)) {
        freopen((name + ".in").c_str(), "r", stdin); 
        freopen((name + ".out").c_str(), "w", stdout);
    }
}
void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
}

void solve(){	
	ll k,n; cin >> k >> n;
	ll cnt = 1;
	if(n == 1){
		cout <<  k;
		return;
	}
	
		ll sum = 0;
		
	vll res;
	if(n% 2 !=0){
		for(ll i = 0;i<n / 2;i++){	
			res.pb((k/n)+cnt);
			sum+=(k/n)+cnt;
			res.pb((k/n) - cnt);
			sum+=(k/n) - cnt;
			cnt++;
		}	
		
		for(ll i = 0;i<n - 1;i++) cout << res[i] << '\n';
		cout << k-sum;
	}else{
		//vll res;
		for(ll i = 0;i<n / 2;i++){
			
			res.pb((k/n)+cnt);
			res.pb((k/n) - cnt);
			cnt++;
		}
		for(ll i = 0;i<n;i++) cout << res[i] << '\n';	
	}
	//cout << sum;	
}
signed main(){
	boost();
	ll test = 1;
	//cin >> test; 
	while(test--) solve(); 
}	

Compilation message

nadan.cpp: In function 'void setIO(std::string)':
nadan.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen((name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nadan.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 1 ms 604 KB Output isn't correct