답안 #1038596

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1038596 2024-07-30T03:12:42 Z Phuoc Nadan (COCI18_nadan) C++14
10 / 50
0 ms 348 KB
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set> 

using namespace std;
 
#define ll long long
#define pb push_back
#define el '\n'
#define mpair make_pair
#define MASK(i) (1LL << (i))
#define BIT(mask, i) (((mask) >> (i)) & 1)
#define fi first
#define se second
 
/* Author: Pham Gia Phuoc */
 
const ll MOD = 998244353;
 
template <class T1, class T2>
    void add(T1 &a, T2 b){
        a += b;
        if(a >= MOD) a -= MOD;
    }
 
template <class T1, class T2>
    void sub(T1 &a, T2 b){
        a -= b;
        if(a < 0) a += MOD;
    }
 
template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if(a > b){a = b; return true;} return false;
    }
 
template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if(a < b){a = b; return true;} return false;
    }
 
/** END OF TEMPLATE. DRINK A CUP OF COFFEE BEFORE READING MY CODE **/
 
const int MAX = 200010;
const ll INF = (ll) 1e18 + 67LL;
const int oo = (int)(1e9 + 7);
const int NUM_BIT = 62;

#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORD(i, a, b) for(int i = a; i >= b; i--)

void init(){
    
}

int ans[MAX];

void solve(int k, int n){
    int t = k / n;
    int styn = k % n;
    if(styn == 0){
        int base = 1;
        FOR(i, 1, n){
            ans[i] = t;
            if(i % 2 && i == n) break;
            if(i % 2) ans[i] += base;
            else{
                ans[i] -= base;
                base++;
            }
        }
    }
    else{
        int base = 1;
        if(base == styn) base++;
        FOR(i, 1, n){
            ans[i] = t;
            if(i % 2 && i == n) break;
            if(i % 2) ans[i] += base;
            else{
                ans[i] -= base;
                base++;
                if(i < n && t + base == ans[1] + styn) base++;
            }   
        } 
        ans[1] += styn;
    }

    FOR(i, 1, n) cout << ans[i] << el;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define test "test"
    // freopen(test".inp", "r", stdin);
    // freopen(test".out", "w", stdout);
    srand(time(0));
    int t = 1;
    while(t--){
        int k, n; cin >> k >> n;    
        solve(k, n);
    }
    
    return 0;
}


 
/*** ROAD TO VOI 2025 ***/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 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 344 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 0 ms 348 KB Output isn't correct