Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; inline int read() { int f = 1, x = 0; char ch; do { ch = getchar(); if (ch == '-') f = -1; } while (ch < '0' || ch > '9'); do { x = x * 10 + ch - '0'; ch = getchar(); } while (ch >= '0' && ch <= '9'); return f * x; } int n, k; int a[100001]; un...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, k; cin >> n >> k; long long i; vector<long long> a; a.resize(k); long long x = (n - (k * (k - 1)) / 2) / k; if (x <= 0) { cout << "NO"; return 0; } lon...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long a[(int)1e5 + 7]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.precision(6); cout << fixed; long long n, k; cin >> n >> k; n -= k * (k + 1) / 2; if (n < 0) { cout << "NO" << endl; return 0; } long long t = n / k; n -= t * k; ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; int main() { long long int n, k; cin >> n >> k; long long int ans[k + 10]; long long int req = (k * (k + 1)) / 2; if (n < req) { cout << "NO" << "\n"; } else if (k == 2 && n == 4) { cout << "NO" << "\n"; } els...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int modpow(int x, int n) { if (n == 0) return 1; long long u = modpow(x, n / 2); u = (u * u); if (n % 2 == 1) u = (u * x); return u; } const int N = int(1e5) + 10; const int K = 11; const int MOD = int(1e9) + 7; const int INF = int(2e9) + 5; const long long INF64 ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long ans[100001]; int main() { long long n, k; cin >> n >> k; long long mini = (k + 1) * k / 2; if (n < mini) { puts("NO"); return 0; } n -= mini; long long temp = n / k; for (int i = 1; i <= k; ++i) { ans[i] = i + temp; } n %= k; for ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
/* Author: Anthony Ngene Created: 25/09/2020 - 05:56 */ import java.io.*; import java.util.*; public class D { // checks: 1. edge cases 2. overflow 3. possible errors (e.g 1/0, arr[out]) 4. time/space complexity void solver() throws IOException { long n = in.intNext(), k = in.intNext(); ...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
def get_tail(k): return (k*(k-1))//2 def find_starter(n, k): f = get_tail(k) starter = (n-f)//k return starter def answerYES(A): return "YES\n"+" ".join(map(str, A)) def get_array(n, k): starter = find_starter(n, k) if starter < 1: return "NO" A = [0]*k s = 0 last = st...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
# AC import sys class Main: def __init__(self): self.buff = None self.index = 0 def next(self): if self.buff is None or self.index == len(self.buff): self.buff = self.next_line() self.index = 0 val = self.buff[self.index] self.index += 1 ...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.util.*; public class npkds { public static void main( String[] args ) { Scanner in = new Scanner( System.in ); int n = in.nextInt(), k = in.nextInt(); int mid; if ( k % 2 == 1 ) mid = n / k; else mid = ( n + ( k / 2 ) ) / k; if ( mid <= k / 2 ) { System.out.println( "NO" ); re...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.*; import java.util.*; public class D { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Solve...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; int a[maxn]; int main() { int n, k; scanf("%d%d", &n, &k); long long ans = 0; for (int i = 1; i <= k; i++) { a[i] = i, ans += i; } if (n < ans) { printf("NO\n"); return 0; } long long res = (n - ans) / k; if (res > 0) ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long N, K; int main() { cin >> N >> K; if (K * (K + 1) / 2 > N) { cout << "NO" << endl; return (0); } long long rem = N - (K * (K + 1)) / 2; if (rem == K - 1) { if (K == 2 || K == 3) cout << "NO" << endl; else if (K == 1) { cout <<...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1}; const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; void faster() { if (0) { freopen( "taskA" ".in", "r", stdin); freopen( ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
rint = lambda: int(input()) rmint = lambda: map(int, input().split()) rlist = lambda: list(rmint()) n, k = rmint() t = k a = [0] * k def no(): print("NO"); exit(0) d = [-1] * (k+1); d[0] = 1 mx = 10 ** 9 for i in range(1, k+1): if d[i-1] * 2 > mx: break d[i] = d[i-1] * 2 for i in range(k): if n < 0: break ...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long N, K; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> K; long long X = K * (K + 1) / 2ll; if (X > N) { cout << "NO\n"; return 0; } vector<long long> res(K); for (int i = 0; i < K; i++) res[i] = i + 1; N -= X; long lon...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); int T; T = 1; while (T--) { long long n, i, j, k; cin >> n >> k; long long ar[k + 1], sum = 0; for (i = 1; i <= k; ++i) { ar[i] = i; sum = sum + i; } if (sum > n) { cout << "NO"...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } int main() { ios_base::sync_with_stdio(false); long long n; cin >> n; long long k; cin >>...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int ans[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, k; cin >> n >> k; long long rest = n - k * (k + 1) / 2; if (rest < 0) { cout << "NO\n"; return 0; } int add = rest / k; rest = res...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.*; import java.util.*; public class BillCalculator { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nex...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int n, k; int a[100005]; int main() { scanf("%d%d", &n, &k); long long sum = 0; for (int i = 1; i <= k; i++) { sum += i; } if (n < sum) { printf("NO\n"); return 0; } a[0] = 0; for (int i = 1; i <= k; i++) { a[i] = a[i - 1] + 1; int com = ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> const long long mod = 1000000007ll, inf = 1e9, linf = 1e18; using namespace std; long long n, k; long long t; long long ans[1024100]; int main() { cin >> n >> k; for (int i = 1; i <= k; i++) { long long p = k - i + 1; long long s = p * (p - 1) / 2; ans[i] = (n - s) / p; if (...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long n, k; int ans[100000]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; long long min_n = k * (k + 1) / 2; if (n < min_n || (n == 4 && k == 2) || (n == 8 && k == 3)) { cout << "NO" << endl; exit(0); } cout <...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Solution { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import sys def check(s, st, n): sum = (st * 2 + (n - 1)) * n // 2 return s >= sum m, n = map(int, input().split()) a = [0] * n last = 0 for i in range(n): le = last + 1 if i == 0: ri = m + 1 else: ri = last * 2 + 1 while ri - le > 1: mid = (le + ri) // 2 if c...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const long long int inf = LLONG_MAX; const long long int mod = 1e9 + 7; const long long int N = 1e6 + 1; long long int get_start(long long int n, long long int k) { long long int s = max(0ll, (n - k * (k - 1) / 2) / k - 1); while (true) { s++; long long int star...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } long long powmod(long long a, long long b, long long MOD) { long long ans = 1; while (b) { if (b % 2) ans = ans * a % MOD;...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long n, k, _n, a[100005]; void Construct() { for (int i = 1; i <= k; i++) { a[i] = _n / k; } for (int i = 1, j = k; i <= _n % k; i++, j--) { a[j] = (_n + k - 1) / k; } for (int i = 1; i <= k; i++) { a[i] += i; } } void Solve() { if (_n == k - ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const long long Nmax = 1e5 + 5; long long bin[Nmax]; long long a[Nmax]; long long n, k, sum; void init() { bin[0] = 1; for (long long i = 0; i <= 100000; i++) { if (i <= 30) bin[i] = bin[i - 1] * 2; else bin[i] = 1e10; } } signed main() { ios_bas...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 10; long long n, k, a[maxn]; int main() { scanf("%lld%lld", &n, &k); long long sum = 0; for (int i = 1; i <= k; i++) { a[i] = i; sum += i; } if (sum > n) { puts("NO"); } else { long long tmp = (n - sum) / k; if (t...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; template <typename... Args> void read(Args &...args) { ((cin >> args), ...); } template <typename... Args> void show(Args... args) { ((cout << args << " "), ...); } void solve() { int64_t n, k; read(n, k); vector<int> v(k); iota(v.begin(), v.end(), 1); int add...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; signed main() { long long n, d; cin >> n >> d; auto foo = [&](long long x) { return (x * x + x) / 2; }; long long start = 0; if (d > 32) { if (foo(d) > n) { cout << "NO" << '\n'; return 0; } start = 1; } long long lo = 1, hi = 1e9; if...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 1e5; long long n, k; long long a[N]; int findA0() { long long left = 1, right = 1e9; while (right - left > 1) { long long mid = (left + right) / 2; ((mid + k) * (mid + k - 1) / 2 - (mid - 1) * mid / 2 <= n ? left : right) = mid; } retur...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
def main(): n, k = map(int, input().split()) if n < k*(k+1)//2: print('NO') else: add = (n-k*(k+1)//2) // k res = [x+add for x in range(1, k+1)] left = n-sum(res) added = True while left > 0 and added: added = False pos = k-1 ...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, ans[100005], k, i, cnt; cin >> n >> m; if (m * (m + 1) / 2 > n || (n == 4 && m == 2) || (n == 8 && m == 3)) cout << "NO" << endl; else { k = (n - m * (m + 1) / 2) / m; cnt = 0; for (i = 0; i < m; i++) { ans[i] =...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
def solve(n, k): u = k * (k - 1) / 2 b = (n - u) / k #print n, u, b, n - b * k - u if b <= 0: return False, [] res = [b for i in xrange(k)] n -= b * k for i in xrange(1, k): res[i] += i n -= i res[-1] += n if n and n == k - 1 and res[-2] * 2 < res[-1]: ...
PYTHON
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
n, k = map(int, input().split()) y = pow(2, k) y = y - 1 x = 0 if(n % y == 0): x = n // y else: x = n // y + 1 if((x + k) * (x + k - 1) / 2 - x * (x - 1) / 2 > n): print("NO") else: a = x n -= x b = [] c = 0 b.insert(c, a) c = c + 1 print("YES") for i in range(1, k): y = ...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long n, k, _n, a[100005]; void Construct() { for (int i = 1; i <= k; i++) { a[i] = _n / k; } for (int i = 1, j = k; i <= _n % k; i++, j--) { a[j] = (_n + k - 1) / k; } for (int i = 1; i <= k; i++) { a[i] += i; } } void Solve() { if (_n == k - ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = (int)1e5 + 100; int main() { long long n, k, a[maxn]; cin >> n >> k; if (k == 1) { cout << "YES\n" << n << endl; exit(0); } for (int i = (1); i <= (k); ++i) { a[i] = i; n -= i; } if (n < 0 || (n == 2 && k == 3) || (n == 1 && k ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import sys # sys.setrecursionlimit(10**6) from sys import stdin, stdout import bisect #c++ upperbound import math import heapq def modinv(n,p): return pow(n,p-2,p) def cin(): return map(int,sin().split()) def ain(): #takes array as input return list(map(int,sin().split...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; public class D { static long[] ans; static class ST { int l, r; long v, lazy; ST left, right; public ST(int l, int r) { this.l = l; this.r = r; ...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const int nsz = 1e5; int n; long long m, sum, ans[nsz + 5]; int main() { ios_base::sync_with_stdio(0); cin >> m >> n; sum = (long long)n * (n + 1) / 2; if (sum > m) { cout << "NO" << '\n'; return 0; } long long pre = 0; for (int i = 1; i <= n; ++i) { ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.Arrays; public class cft7 { static int[] arr; public static void main(String[] args) { FastReader fr=new FastReader(); int n=fr.nex...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long a[100005]; int main() { long long n, k; cin >> n >> k; long long sum = 0; long long begin = max((long long)1, (2 * n / k - k + 1) / 2); while ((begin + begin + k - 1) * k / 2 <= n) { begin++; } begin--; if (begin == 0) { cout << "NO" << '\n...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const double PI = 3.14159265; vector<int> prime; bool is_composite[100000009]; void sieve(int n) { fill(is_composite, is_composite + n, false); for (int i = 2; i < n; ++i) { if (!is_composite[i]) prime.push_back(i); for (int j = 0; j <...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; vector<long long> A; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long k, n; cin >> n >> k; n -= k * (k + 1) / 2; if (n < 0) { cout << "NO" << endl; return 0; } A.resize(k); iota(A.begin(), A.end(), 1 + n / k); n %= k; for (...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long NSD(long long a, long long b) { while (a != 0 && b != 0) { if (a > b) a %= b; else b %= a; } return a + b; } long long step(long long a, long long b) { if (!b) return 1; if (b == 1) return a; long long c = step(a, b / 2); if (b & ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.util.*; import java.io.*; import java.math.BigInteger; import static java.lang.Math.*; public class Main { static final int mod = (int)1e9+7; static ArrayList<Integer>[] adj; public static void main(String[] args) throws Exception { FastReader in = new FastReader(); PrintWriter out = new PrintWrit...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; long long sum = n - 1LL * k * (k + 1) / 2; if (sum < 0) { cout << "NO" << endl; return 0; } for (int i = 1; i <= k; i++) a[i] = i;...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { static final long mod=(int)1e9+7; public static void main(String[] args) throws Exception { FastReader in=new FastReader(); PrintWriter pw=new PrintWriter(System.out); long n=in.nextLong(); int k=in.nextInt(); long[] ar...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author cunbidun */ public class M...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 2e5 + 2; long long n, k, t, base, sum; long long a[maxn]; void die() { cout << "NO"; exit(0); } int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); cin >> n >> k; base = (k + 1) * k / 2; if (bas...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
n, k = map(int, input().split()) if n < k * (k + 1) / 2: print('NO') else: ar = [i + 1 for i in range(k)] n -= k * (k + 1) // 2 c = n // k s = n % k for i in range(k): ar[i] += c j = k - 1 while s > 0: ar[j] += ar[j - 1] - 1 s -= ar[j - 1] - 1 if s < 0: ...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long ans[100001]; int main(int argc, char const *argv[]) { long long n, k; cin >> n >> k; long long l = 1, r = n; long long temp = n; bool done = false; while (l <= r) { n = temp; long long mid = (l + r) / 2; if (n < mid * k + k * (k - 1) / 2) {...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int main() { long long N, K; cin >> N >> K; long long B = (N - K * (K - 1) / 2) / K; if (B < 1) { cout << "NO\n"; return 0; } vector<int> res(K); long long s = 0; for (int i = 0; i < K; i++) { res[i] = B + i; s += res[i]; } int index = K ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; long long a[100005]; int32_t main() { std::ios::sync_with_stdio(0); std::cin.tie(0); ; long long n, k; cin >> n >> k; long long d = n - k * (k + 1) / 2; for (long long i = 0; i < k; i++) a[i] = i + 1; if (d < 0) { cout << "...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.*; import java.math.BigInteger; import java.util.*; public class template { public static void main(String[] args) throws IOException { FastReader scan = new FastReader(); //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("cowmbat.out"))); PrintWriter out = new PrintWriter(new...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import sys n, k = map(int, raw_input().split()) def search(i, j): hi = i * (2 ** k - 1) lo = k * i + (k-1)*k/2 if lo <= n <= hi: return i while i <= j: mid = (i + j) / 2 hi = mid * (2 ** k - 1) lo = k * mid + (k-1)*k/2 if lo <= n <= hi: return mid elif hi < n: i = mid + 1 else: j = mid - 1 ...
PYTHON
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const int MAX = 0x3f3f3f3f; int main() { long long n; long long k; cin >> n >> k; if (k == 1) { cout << "YES" << endl; cout << n; return 0; } long long leastcost = ((1 + k) * k / 2); if (n < leastcost) { printf("NO\n"); return 0; } long...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; long long n, k; long long judge(long long a) { return (a + a + (k - 1)) * k / 2; } int a[maxn]; int main() { cin >> n >> k; if (judge(1) > n) { cout << "NO" << endl; return 0; } long long l = 1; long long r = n; while (l < r) {...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; void bit() { cout << "NO" << endl; exit(0); } int main() { long long n, k; cin >> n >> k; long long sum = 0; vector<long long> arr; for (int i = 1; i <= k; i++) { arr.push_back(i); sum += i; } if (sum > n) bit(); long long kalan = n - sum; vect...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import static java.lang.Double.parseDouble; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Math.*; import static java.lang.System.exit; import java.io.*; import java.math.BigInteger; import java.util.*; public class A { static BufferedReader in; stat...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.InputMismatchException; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Exce...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
def check(n, k, fl, fr): if n < k * (2 * fl + k - 1) // 2: return 1 if k <= 32 and n > fr * (2**k - 1): return -1 return 0 def main(): n, k = map(int, input().split(' ')) l, r = 1, n ans = [] while k > 0: ll, rr = l, r cnt = -1 while rr >= ll: ...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const int KMAX = 1e5 + 5; long long n, k; long long arr[KMAX]; void solve() { cin >> n >> k; memset(arr, 0, sizeof arr); arr[0] = (long long)1e10; long long sum = 0; for (long long i = 1; i <= k; i++) { arr[i] = i; sum += ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int n, k, nn; int a[200010]; inline bool check() { long long cur_ans = a[1]; for (int i = 2; i <= k; i++) { if (a[i] <= a[i - 1]) { return false; } if (a[i] > a[i] * 2) { return false; } cur_ans += a[i]; } if (cur_ans != 1ll * nn) ret...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
n, k = map(int, raw_input().strip().split()) p = float('inf') if k <= 32: p = 2 ** k - 1 lo = 1 if n >= p: lo = (n + p - 1) // p if 2 * n <= k * (k - 1): print "NO" exit() hi = (n - (k * (k - 1)) // 2) // k if hi < lo: print "NO" exit() lista = [] flag = 0 while k: a = (n - (k * (k - ...
PYTHON
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long n, k, tot, rim, rim2, add, last_ele; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); ; cin >> n >> k; tot = k * (k + 1) / 2; if (n < tot) cout << "NO" << endl; else { rim = n - tot; add = rim / k; ; rim2 = rim % k; ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
from sys import stdin from collections import defaultdict as dd from collections import deque as dq import itertools as it from math import sqrt, log, log2, ceil, floor from fractions import Fraction n, k = map(int, input().split()) l = floor((2*n + k - k**2)/(2*k)) rem = abs(n - ((l + l + k - 1)*(k))//2) ans = list(r...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void solve() { long long n, k; cin >> n >> k; vector<long long> a(k); long long excess = n - ((k * (k + 1)) / 2); if (excess < 0) { cout << "NO" << "\n"; } else ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.util.*; import java.lang.*; import java.io.*; import java.awt.*; // U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................ //JUst keep faith in ur strengths .................................................. // ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 10 base 2 ...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; const long long int p_mod = 9999999999999983; const long double pi = 3.14159265358979323; const long long int N = 1e6 + 9; const long long int mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { uniform_int_distribu...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import sys input = sys.stdin.readline ''' ''' from math import floor, ceil s = lambda n: n*(n+1)/2 n, k = map(int, input().split()) if n < s(k): print("NO") else: # s(k) + xk = n x = (n - s(k)) / k if x % 1 == 0: print("YES") print(*[int(i+x) for i in range(1, k+1)]) else: ...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import sys,math from fractions import gcd from bisect import bisect_left, bisect from collections import defaultdict from io import BytesIO sys.stdin = BytesIO(sys.stdin.read()) input = lambda: sys.stdin.readline().rstrip('\r\n') #n = int(input()) n,k = [int(_) for _ in input().split()] #b = [int(_) for _ in input().sp...
PYTHON
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
n, k = [int(i) for i in input().split()] def ok(a): print("YES") print(*a) if k * (k + 1) // 2 > n: print("NO") else: v = (n - k * (k + 1) // 2) // k a = [v + i for i in range(1, k + 1)] if v == 0: if k == 2: if sum(a) != n: print("NO") else: ...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<long, long>; double pi = 3.1415926535897932384626433; long mod = 998244353; long long min_(long long a0, long long k) { return k * a0 + k * (k - 1) / 2; } long long max_(long long a0, long long k) { return a0 * ((1 << k) - 1); } int ma...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; constexpr int MAXK = 1e5 + 15; vector<int> ans(MAXK); inline int can(long long k, long long n, long long mid) { long long lb = mid * k + 1LL * k * (k - 1) / 2; long long ub = (k > 32 ? (long long)1e10 : mid * ((1LL << k) - 1)); if (lb <= n && n <= ub) return 0; ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; void cmax(long long int &a, long long int b) { if (a < b) a = b; } const int mod = 1000000007; bool comp(int x, int y) { return x > y; } void printarr(int arr[], int n) { for (int i = 0; i < n; ++i) std::cout << arr[i] << (i < n - 1 ? ' ' : '\n'); } template <typename T...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) const double PI = acos(-1); const long long N = 500005, md = 1e9 + 7, inf = 1e18, iinf = 1e9 + 5, MX = 3e5; long long g, w, h, x, y, z, i, j, k, q, n, cnt, res, sum, r[N], a[N], b[N]; char c[N]; string s, t; pair<int, int> p[N]; vector<int> e...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
n,k=map(int,input().split()) s=(k*(k+1))//2 a=[] if k==1: print('YES') print(n) exit() if n-s<0: print('NO') exit() c=(n-s)//k r=(n-s)%k if (k==2 and r==1 and c==0) or (k==3 and r==2 and c==0): print('NO') exit(0) for i in range(k): if i<k-r: a.append(i+1+c) else: ...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.*; import java.util.Arrays; import java.util.StringJoiner; import java.util.StringTokenizer; public class Main { static int N, K; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); N = sc.nextInt(); K = sc.nextInt(); int[] ans...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> const long long inf = 0x3f3f3f3f3f3f3f3LL; const long long mod = (long long)1e9 + 7; using namespace std; template <class T> void smin(T& a, T val) { if (a > val) a = val; } template <class T> void smax(T& a, T val) { if (a < val) a = val; } const long long N = 5 * (long long)1e5 + 10; long...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
//package com.example.hackerranksolutions; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Temp { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] ins =...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int lowbit(int x) { return x & (-x); } const int maxn = 2e5 + 5; int add, a[maxn]; int n, k; bool can(void) { if (n < (long long)(k + 1) * k / 2) return false; return true; } int main(void) { scanf("%d%d", &n, &k); if (can()) { long long tot = (long long)(k + 1)...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; while (cin >> n >> k) { if (k == 1) { cout << "YES" << endl; cout << n << endl; } else if (k == 2) { if (n < 3 || n == 4) { cout << "NO" << endl; } else { if (n % 3 == 0) { cout <...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
// Imports import java.util.*; import java.io.*; public class D1157 { /** * @param args the command line arguments * @throws IOException, FileNotFoundException */ public static void main(String[] args) throws IOException, FileNotFoundException { // TODO UNCOMMENT WHEN ALGORIT...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.*; import java.util.*; public class C { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(); PrintWriter out = new PrintWriter(System.out); int n=sc.nextInt(),k=sc.nextInt(); if(k==1) { System.out.printf("YES\n%d\n",n); return; } long sum=k*1L*(k+1)...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) throws Exception { FastReader in = new FastReader(); long n = in.nextLong(); long k = in.nextLong(); long[] ans = new long[(int)k]; for(...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
n,k = list(map(int,input().split())) if(n < k*(k+1)/2): print("NO") exit(0) dif = n - k*(k+1)//2 a = [i+1+dif//k for i in range(k)] dif %= k if(dif == 0): print("YES") print(*a) exit(0) if(a[-1]+dif > 2*a[-2]): if(k == 2): print("NO") exit(0) if(a[-2] == 2*a[-3]): print("NO") exit(0) a[-2] += 1 a[-1] +...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.*; import java.util.*; public class CF1157D { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int k = Integer....
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
m, n=map(int, input().split()) a=[0]*n d=0 for i in range(n): a[i]+=i+1 if sum(a)>m: d=1 for i in range(n): a[i]+=(m-(n+1)*n//2)//n k=n-1 if d==0: while sum(a)<m: if (m-sum(a))>=a[k-1]*2-a[k]: a[k]+=a[k-1]*2-a[k] else: a[k]+=m-sum(a) k-=1 c=0 for i in ran...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import java.io.*; import java.util.*; public class Main { public static final int PROBLEM = 1; static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { br = new BufferedReader(new InputStreamReader(Syst...
JAVA
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long a[110000]; long long s(long long m) { return m * (m + 1) / 2; } int main() { int n, k; cin >> n >> k; for (int i = 1; i <= k; i++) { long long ans = max((int)(a[i - 1] + 1), (int)ceil((double)n / (double)(pow(2.0, k + 1 - i) - 1))); ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import sys n, k = map(int, input().split()) min_cnt = k * (k + 1) // 2 if n < min_cnt: print("NO") sys.exit() # min_cnt + k * t <= n # t <= (n - min_cnt) // k # t <= floor((n - min_cnt) // k) t = (n - min_cnt) // k assert(t >= 0) delta = n - (min_cnt + k * t) a = [i + t for i in range(1, k + 1)] # print(...
PYTHON3
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<long, long>; double pi = 3.1415926535897932384626433; long mod = 998244353; long long min_(long long a0, long long k) { return k * a0 + k * (k - 1) / 2; } long long max_(long long a0, long long k) { return a0 * ((1 << k) - 1); } int ma...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; if (n < k * 1ll * (k + 1) / 2) { cout << "NO" << endl; return 0; } int nn = n - k * (k + 1) / 2; vector<int> a(k); for (int i = 0; i < k; ++i) a[i] = i + 1 + (nn / k) + (i >= k - nn % k); if (nn != k - 1) { c...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
def fun(x1, x2, i, s): # print (x,i,s) j = 31 if i < 32:j = i z1 = i*(2*x1 + i - 1)/2 z2 = x2*(2**j-1) if s < z1 or s > z2 or x2 < x1: return 0 y1 = (2*s + i - i*i)/(2*i) y2 = s*x2/z2 if (s*x2)%z2 > 0:y2 += 1 if y1<x1 or y2>x2 or y1<y2:return 0 return...
PYTHON
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
#include <bits/stdc++.h> using namespace std; long long m, n, a[100010], s; bool ok = true; int main() { cin.tie(0), cout.sync_with_stdio(false); cin >> m >> n; if (n == 1) { cout << "YES\n" << m << '\n'; return 0; } s = m - ((n + 1) * n / 2); if (s < 0) ok = false; for (int i = 1; i <= n; i++) { ...
CPP
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
import math import operator import sys from collections import Counter, defaultdict from math import ceil, floor, pi, sin, sqrt from sys import exit, stdin, stdout def main(): # stdin = open('.in') [n, k] = map(int, stdin.readline().strip().split(' ')) ans = range(1, k + 1) n -= sum(ans) if n < 0:...
PYTHON
1157_D. N Problems During K Days
Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to sol...
2
10
n, k = [int(i) for i in input().split()] def ok(a): print("YES") print(*a) if k * (k + 1) // 2 > n: print("NO") else: v = (n - k * (k + 1) // 2) // k a = [v + i for i in range(1, k + 1)] if v == 0: if k == 2: if sum(a) != n: print("NO") else: ...
PYTHON3