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
1139_D. Steps to One
Vivek initially has an empty array a and some integer constant m. He performs the following algorithm: 1. Select a random integer x uniformly in range from 1 to m and append it to the end of a. 2. Compute the greatest common divisor of integers in a. 3. In case it equals to 1, break 4. Otherwise, return to...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; const long long MOD = 1e9 + 7; long long poww(long long a, long long b) { long long z = 1; while (b > 0) { if (b % 2) z = z * a % MOD; a = a * a % MOD; b /= 2; } return z; } long long a[N], b[N], f[N]; int main() { int n; scanf...
CPP
1139_D. Steps to One
Vivek initially has an empty array a and some integer constant m. He performs the following algorithm: 1. Select a random integer x uniformly in range from 1 to m and append it to the end of a. 2. Compute the greatest common divisor of integers in a. 3. In case it equals to 1, break 4. Otherwise, return to...
2
10
import java.util.Arrays; public class Main { private static void solve() { int m = ni(); int mod = 1000000000 + 7; int[] primes = sieveEratosthenes(m + 1); long[] dp = new long[m + 1]; long ret = 0; outer: for (int g = 2; g <= m; g ++) { dp[g] = f(m, g, mod); int...
JAVA
1139_D. Steps to One
Vivek initially has an empty array a and some integer constant m. He performs the following algorithm: 1. Select a random integer x uniformly in range from 1 to m and append it to the end of a. 2. Compute the greatest common divisor of integers in a. 3. In case it equals to 1, break 4. Otherwise, return to...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long p = 1e9 + 7; long long dp[N]; long long mult(long long a, long long b) { long long res = a * b % p; if (res < 0) res += p; return res; } long long add(long long a, long long b) { long long res = a + b; if (res < -p) res +...
CPP
1139_D. Steps to One
Vivek initially has an empty array a and some integer constant m. He performs the following algorithm: 1. Select a random integer x uniformly in range from 1 to m and append it to the end of a. 2. Compute the greatest common divisor of integers in a. 3. In case it equals to 1, break 4. Otherwise, return to...
2
10
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1000000007; long long int N, M, K, H, W, L, R; long long int power(long long int x, long long int n, long long int M) { long long int tmp = 1; if (n > 0) { tmp = power(x, n / 2, M); if (n % 2 == 0) tmp = (tmp * tmp) % M; else ...
CPP
1139_D. Steps to One
Vivek initially has an empty array a and some integer constant m. He performs the following algorithm: 1. Select a random integer x uniformly in range from 1 to m and append it to the end of a. 2. Compute the greatest common divisor of integers in a. 3. In case it equals to 1, break 4. Otherwise, return to...
2
10
/*Author: Satyajeet Singh, Delhi Technological University*/ import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Main{ /*********************************************Constants******************************************/ static PrintWriter...
JAVA
1139_D. Steps to One
Vivek initially has an empty array a and some integer constant m. He performs the following algorithm: 1. Select a random integer x uniformly in range from 1 to m and append it to the end of a. 2. Compute the greatest common divisor of integers in a. 3. In case it equals to 1, break 4. Otherwise, return to...
2
10
import java.lang.*; import java.math.*; import java.util.*; import java.io.*; public class Main { void solve() { int m=ni(); precompute(m); long dp[]=new long[m+1]; int cnt[]=new int[m+1]; dp[1]=1; for(int x=2;x<=m;x++) { for(int j=div[x].size()-1;j>=0;j...
JAVA
1139_D. Steps to One
Vivek initially has an empty array a and some integer constant m. He performs the following algorithm: 1. Select a random integer x uniformly in range from 1 to m and append it to the end of a. 2. Compute the greatest common divisor of integers in a. 3. In case it equals to 1, break 4. Otherwise, return to...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 200000 + 10; const int M = 100000 + 10; const int MOD = 1e9 + 7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t, n, m, k, q; int ans, cnt, flag, temp, sum; int a[N]; char str; struct node {}; long long powl(long long a...
CPP
1139_D. Steps to One
Vivek initially has an empty array a and some integer constant m. He performs the following algorithm: 1. Select a random integer x uniformly in range from 1 to m and append it to the end of a. 2. Compute the greatest common divisor of integers in a. 3. In case it equals to 1, break 4. Otherwise, return to...
2
10
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1000000007; const int maxm = 100010; int m; ll ev[maxm]; int fact[maxm]; ll mult(ll a, ll b) { return (a % mod) * (b % mod) % mod; } void add(ll& a, ll b) { a = (a + mod + b) % mod; } bool isprime(int u) { for (int i = 2; i * i <= u; ...
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 pi = 2 * acos(0.0); const int maxn = 2e5 + 10; vector<int> ans; int main() { int n, k; cin >> n >> k; int l = 1, r = 1e9; while (l <= r) { int mid = (l + r) >> 1; long long res = 1LL * (mid + mid + k - 1) * k / 2; if (res <= n) l = mid...
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 >> k >> n; long long cur = (n * (n + 1)) / 2; vector<int> ans(n); iota(ans.begin(), ans.end(), 1); if (cur > k) { cout << "NO"; return 0; } if ((k - cur) / n > 0) { int add = (k - cur) / n; for (int i = 0; i < int(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
import java.util.*; import java.io.*; public class Main { public static long sum(long a){ return ((a*(a+1))/2); } public static boolean check(long goal , long n ,long[] arr , long z){ long pro = 1L; long s=1L; s = (1 - (long) Math.pow(2,(int) (n))) / (1 - 2); // System.out.println(s); long a1=(goal-sum(n...
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 N = 1e6; const long long inf = 1e18; long long AP(long long n, long long first, long long df) { if (n > 1e5) return inf; long long ret = 2 * first + (n - 1) * df; return (ret * n) / 2; } long long GP(long long n, long long first, long long fc) { if (n >= 3...
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 = 200020; inline long long read() { char ch = getchar(); long long x = 0, f = 0; while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return f ? -x : x; } int n, k, ans[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; const int inf = 0x3f3f3f3f; const long long _64inf = 0x3f3f3f3f3f3f3f3f; const int MAX = 1e5 + 5; const int Mod = 1e6 + 3; long long n; int k; int main() { cin >> n >> k; vector<int> a(k + 1); long long sum = 0; for (int i = 0; i < k; i++) { a[i] = i + 1; su...
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; using ll = long long; using ld = long double; const ll inf = 1e18; const ll mod = 1e9 + 7; const ll MOD = 998244353; const ll MAX = 2e5; inline ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; } inline ll sub(ll a, ll b) { return ((a % mod) - (b % mod) + mod) % mo...
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 test { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; PrintWriter out = new PrintWriter(outputStream); InputReader in = new InputReader(inp...
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 range = xrange input = raw_input n,k = [int(x) for x in input().split()] mini = list(range(1,k+1)) score = sum(mini) if score>n: print 'NO' sys.exit() diff = (n - score) add = diff//k mini = [x + add for x in mini] score += add*k i = k-1 while score<n: while i>0 and 2*mini[i-1]==mini[i]:...
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
import java.util.Scanner; import java.util.Stack; // http://codeforces.com/problemset/problem/1157/D public class NProblemsDuringKDays { public static void main(String[] args) { // collect test data from input Scanner inputScanner = new Scanner(System.in); int sum = inputScanner.nextInt(); ...
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 N = 1e5 + 5; long long n, k, s, d; long long a[N]; signed main() { scanf("%lld%lld", &n, &k); for (long long i = 1; i <= k; i++) a[i] = i, s += a[i]; if (s > n) { printf("NO\n"); return 0; } d = (n - s) / k; for (long long i = 1; i <= 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 java.io.*; import java.util.*; public class Main { public static void main(String args[]) { FastReader input=new FastReader(); PrintWriter out=new PrintWriter(System.out); int T=1; while(T-->0) { long n=input.nextInt(); int k=input.nextInt()...
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
""" b[i] = a[i] - i - 1 b[i] <= b[i+1] < 2b[i] + i - 1 sum(b) == r """ def solve(n, k): r = n - k*(k+1)//2 if r < 0: return None b0 = r//k r -= b0*k seq = [None]*k seq[0] = b0 b = b0 for i in range(1,k): bn = b*2 + i - 1 h = r//(k-i) if h > 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; int in() { int x; scanf("%d", &x); return x; } long long lin() { long long x; scanf("%lld", &x); return x; } int main() { long long x, n; cin >> x >> n; vector<long long> ans(n); for (int i = 0; i < n; ++i) { long long p = n - i; long long s = p ...
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.math.*; public class Animal { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); long n=scanner.nextInt(); long k=scanner.nextInt(); int a[]=new int [(int)(k+5)];long pre=0;long x;int fl=0; for(long i=k;i>=1;i--) { x=(2*n/i-i+1)/2; x=Math...
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 input = sys.stdin.readline n, k = map(int, input().split()) s = k * (k + 1) // 2 if n < s: ans = "NO" else: j = (n - s) // k a = [i + j for i in range(1, k + 1)] ans = "NO" x = a[0] c = 0 for _ in range(k): c += x x *= 2 if n <= c: ans = "YES" ...
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
rr = raw_input rrm = lambda: map(int, raw_input().split()) from collections import deque def solve(N,K): if K == 1: return [N] # len(A) == K # sum(A) == N # A[i] > 0 # A[i] < A[i+1] <= 2A[i] # Lets try to find differences P[i] = A[i+1] - A[i] > 0 # min sum is 1 + 2 + ... + K triangle = ...
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; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, k; cin >> n >> k; long long int p = (n - (k * (k - 1) / 2)) / k; long long int q = n / (pow(2, k) - 1); if (p >= q) { if (p > 0) { long long int arr[k]; arr[0] = p; ...
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 double pi = 4.0 * atan(1.0); const double e = exp(1.0); const int maxn = 1e6 + 8; const long long mod = 1e9 + 7; const unsigned long long base = 1e7 + 7; using namespace std; long long qpow(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) { ans *= a; ...
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.*; public class NProblemsKDays { public static void main(String[] args) { FastScanner scanner = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int N = scanner.nextInt(); int K = scanner.nextInt(); long k = (long) K; ...
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.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
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.util.*; import java.io.*; public class A101177 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); int k = sc.nextInt(); if (n < 1l * k * (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.util.*; public class Class{ public static long getLow(long y,int x){ long last=y+x-1; if(x%2==0)return ((y+last)*(x/2)); else return ((y+last)*(x/2))+(y+last)/2; } public static long getHigh(long y,int x){ return y*((long)Math.pow(2,x)-1); } public static void main(String[] args){ ...
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 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 - ...
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 MOD = 1000000007; long long n, m, i, j, Q, k, l, T, a[300001], b[300001], c[300001], hod = 0, mx = 0; string s, ans; int main() { long long q; cin >> n >> q; if (n < q * (q + 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; vector<int> res; bool fill_res(int n, int k) { int low = 1, high = n; while (n != 0 || k != 0) { double w = pow(2.0, k + 0.0) - 1.0; double a = (n + 0.0) / w; double b = ((n + 0.0) / (k + 0.0)) - ((k - 1.0) / 2.0); if (floor(a) == a || floor(b) == 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
n, k = [int(i) for i in input().split()] s = int(k * (k + 1) / 2) a = [] # print(n, k, s) if k == 1: print('YES') print(n) exit(0) if n - s < 0: print('NO') exit(0) 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...
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 Task { public static void main(String[] args) throws IOException { new Task().go(); } PrintWriter out; Reader in; BufferedReader br; Task() throws IOException { try { //br = new BufferedReader( new FileReader("...
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 mp(): return map(int, input().split()) n, k = mp() a = [i for i in range(1, k + 1)] s = (1 + k) * k // 2 p = [0] * k pp = 0 i = 0 while i < k and s < n: #print((n - s), (k - i), (n - s) // (k - i)) q = (n - s) // (k - i) if i == 0 or a[i] + q <= 2 * a[i - 1] + pp: p[i] = q pp += q...
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() { 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 - ...
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()) max_x = (n - k * (k - 1) // 2) / k if max_x < 1: print('NO') exit(0) x = int(max_x) r = n - (k * x + k * (k - 1) // 2) A = [x + i for i in range(k)] p = r + 1 while r > 0 and r != p: p = r for i in range(k - 1, 0, -1): q = min(r, 2 * A[i - 1] - A[i]) 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
import sys n,k=map(int,input().split()) a=[0]*(k+2) if k*(k+1)>n*2: print("NO") sys.exit() for i in range(1,k+1): a[i]=i n-=k*(k+1)//2 rest=n//k n-=rest*k a[1]+=rest for i in range(2,k+1): a[i]=a[i-1]+1 rest=n//(k-i+1) tmp=min(rest,a[i-1]*2-a[i]) a[i]+=tmp n-=(k-i+1)*tmp if n>0: pri...
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.*; import java.lang.*; import java.io.*; public class Main { PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next() throws IOException { if (!tok.hasMoreToke...
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 mod = 1e9 + 7; const long long INF = 4e18 + 10; long long power(long long a, long long b, long long in_mod) { long long ans = 1; long long prod = a; while (b) { if (b % 2) ans = (ans * prod) % in_mod; prod = (prod * prod) % in_mod; b /= 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; const long long int N = 400005; const long long int LG = 22; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int k, n; cin >> n >> k; long long int a[k + 1]; for (long long int i = 0; i <= k; i++) a[i] = 0; a[1] = 1; 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
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), k = in.nextInt(); if(1L * k * (k + 1) / 2 > n) { println("NO"); return; } n -= 1L * k * (k ...
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 mx = 2e5 + 5; long long n, s[mx], cnt, k; void bepok() { cout << "NO" << endl; exit(0); } int32_t main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> k; if (n < (k * (k + 1) / 2)) { bepok(); } if (k == 2 && n == 4) { ...
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(nullptr); long long n, k; cin >> n >> k; if (k * (k + 1) / 2 > n) { cout << "NO"; return 0; } if (k == 1) { cout << "YES\n"; cout << n; return 0; } if (k == 2) { if (n % 2 == 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; long long mod = 998244353; long long mod1 = 1e9 + 7; const int N = 2e5 + 9; long long n, a[N], k; long long tot; int main() { cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false); cin >> n >> k; if (n < (k * (k + 1)) / 2) { 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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
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())) mi = (k * (k+1))//2 mx = 2**(k-1) if n<mi: print('NO') else: ans = [] for i in range(1, k+1): ans.append(i) remain = n-mi add = remain//k if add: for i in range(k): ans[i]+=add remain-=(k*add) while remain: i = k-1 while remain and ans[i] < (add + ans[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 N, res, k, ans[100010]; bool check() { long long i; for (i = 1; i < k; i++) if (ans[i + 1] <= ans[i] or ans[i + 1] >= 2 * ans[i]) return false; return true; } int main() { long long i; cin >> N >> k; res = N; for (i = 1; i <= k; 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
# Author : raj1307 - Raj Singh # Date : 05.07.2020 from __future__ import division, print_function import os,sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip def ii(): return int(input())...
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
import java.io.PrintWriter; import java.util.Scanner; public class NProblemsDuringKDays { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = 1; for (int i = 0; i < t; i++) { solve(sc, pw); ...
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; bool check(long long int x, long long int k, long long int n) { long long int a1 = x, an = x + k - 1; long long int sum = (k * (a1 + an)) / 2; if (sum >= n) return true; else return false; } int main() { long long int n, k; cin >> n >> k; long long int...
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
#Code by Sounak, IIESTS #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase from fractions import Fraction import collections from itertools import permutations from collections import defaultdict from collections import deque import threadi...
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.Scanner; /** * * @author htdong * @date 2018εΉ΄4月20ζ—₯ 上午11:52:19 */ public class Main { static class SegmentTree { private int[] tr; public SegmentTree(int n) { tr = new int[n << 1]; } private int idx(int l, int r) { return (l + r) | (l ...
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.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); long sum = (long)(1+k)*k/2; if(n<sum || (n==4&&k==2) || (n==8&&k==3)) { System.out.println("NO"); } else { long res = n-sum; long ad...
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 sum, k, ans[100005], tmp; int main() { scanf("%lld%lld", &sum, &k); ans[k + 1] = 2147483647; if ((k + 1) * k / 2 > sum) { printf("NO\n"); return 0; } sum -= 1ll * (k + 1) * k / 2; for (register int i = 1; i <= k; i++) { ans[i] = i + sum / 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
kk=lambda:map(int,input().split()) # k2=lambda:map(lambda x:int(x)-1, input().split()) ll=lambda:list(kk()) n,k =kk() su = ((k+1)*k)//2 start = (n-su)//k + 1 if n < su or n > start*((2**k)-1): print("NO") exit() ls = [start+i for i in range(k)] currsum = (start-1)*k+su delayed = 0 for i in range(1, k): ls[i]+=delaye...
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
n, k = [int(i) for i in input().split()] s = int(k * (k + 1) / 2) a = [] # print(n, k, s) if k == 1: print('YES') print(n) exit(0) if n - s < 0: print('NO') exit(0) 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...
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 int maxn = 3e5 + 5; const long long mod = 998244353; const int inf = 0x3f3f3f3f; long long co[maxn], ww[maxn], cnt[maxn]; string str; long long dp[1005][1005]; long long n, m, k, t, now = 0; long long getmid(int i) { long long l = 0, r = 1e9, ans; 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
''' Aakash Pahwa ( @aakash10399 ) Hi There! :D queue.Queue() queue.LifoQueue() , basically stack math.gcd() pow(a,b,m) pow(a,m-2,m) , mod inverse fermat's theorem math.log(a,b) math.ceil() floor() ''' import heapq import queue from collections import * import math import sys de...
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 int INF = 0x3f3f3f3f; const double PI = acos(-1); const double eps = 1e-8; const int Mod = 1e9 + 7; const int MaxN = 1e6 + 5; int a[MaxN], presum[MaxN]; int n, sum; void add(int p, int x) { for (int i = p; i <= n; i += i & (-i)) presum[i] += x; } int getSum(int p) {...
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 cplayer on 2018/6/23. * @version 1.0 */ import java.util.*; import java.util.stream.Collectors; import java.io.*; import java.lang.*; public class Main { public static void main(String[] args) { try { InputReader in; PrintWriter out; boolean useOutput = false; if (System.getProperty(...
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 solve(n, k): if (k+1)*k // 2 > n: return '' if k == 1: return str(n) if k == 2: if n % 2: return '%d %d' % (n//2, n//2+1) else: if n <= 4: return '' return '%d %d' % (n//2-2, n//2+2) s = (k+1)*k // 2 t, m = divmod(n, s) res = [v*t for v in range(1, k+...
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
def solve(): N, K = map(int, input().split()) result = list(range(1, K+1)) Sum = (K*(K+1))//2 if N < Sum: print ("NO") return add = (N - Sum)//K for i in range(K): result[i] += add add = (N - Sum) % K i = K-1 while i > 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; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long n; int k; cin >> n >> k; if (n < (1ll * k * (k + 1)) / 2) { cout << "NO"; return 0; } if ((n == 8 && k == 3) || (n == 4 && k == 2)) { cout << "NO"; return...
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 = [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; const long long MAXN = 300500; const long long PHI = (long long)1e9 + 6; const long long INF = 0x3f3f3f3f; const long long LINF = 0x1f3f3f3f3f3f3f3f; const long long MOD = (long long)1e9 + 7; const long long OVER_FLOW = 0xffffffff; long long n; long long buf[MAXN]; int main...
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; namespace nyuuryoku { const int STRSZ = 3e5 + 13; char inbufer[STRSZ]; inline void cscan(string& i) { int c = getc(stdin), cnt = 0; while (c <= 32) c = getc(stdin); while (c > 32) *(inbufer + cnt) = c, c = getc(stdin), ++cnt; *(cnt + inbufer) = 0; i = inbufer; } 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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.Input...
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 main() { long long int n, k; cin >> n >> k; long long int sum = (k * (k + 1)) / 2; if (n < sum) { cout << "NO"; return 0; } n -= sum; int y = n / k; vector<int> Ans(k + 1, 0); for (int i = k; i > 0; i--) { Ans[i] = i + y; } for (int 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
#include <bits/stdc++.h> using namespace std; long long n, k, n2, n3; long long a[100009]; int main() { scanf("%lld%lld", &n, &k); n3 = n; if (n < (k) * (k + 1) / 2) { printf("NO"); return 0; } n2 = n - (k - 1) * k / 2; a[0] = n2 / k; for (int i = 1; i < k; i++) a[i] = a[i - 1] + 1; n -= (a[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
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), k = in.nextInt(); long minimum = 1L * k * (k + 1) / 2; if(minimum > n) { println("NO"); return; ...
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
# ========= /\ /| |====/| # | / \ | | / | # | /____\ | | / | # | / \ | | / | # ========= / \ ===== |/====| # code if __name__ == "__main__": n,k = map(int,input().split()) x = (k*(k+1))//2 y,s = 0,0 a = [] ...
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> int main() { using namespace std; long long n, k; cin >> n >> k; long long first, left, tmp, k_tri = (k * (k + 1)) / 2; if (k_tri > n) { cout << "NO\n"; return 0; } first = (n - k_tri) / k + 1; left = n - k_tri - (first - 1) * k; vector<long long> A(k); A[0] = first;...
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 Main { static ArrayList a[]=new ArrayList[3000001]; static boolean prime[]=new boolean [3000001]; public static void main(String[]args) { InputReader in=new InputReader(System.in); PrintWriter pw = new PrintWriter(System.out...
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 N = 1e5 + 7; const long long xinc[] = {0, 0, 1, -1}; const long long yinc[] = {1, -1, 0, 0}; const long double PI = acos(-1.0); long long n, k; long long a[N]; void ansno() { cout << "NO" << '\n'; exit(0); } long long sum(long long a, long long n) { retu...
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
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 int N = 1e5 + 7; using namespace std; long long ans[N]; int main() { long long i, j, k, n, m, sum, a0; scanf("%lld%lld", &n, &k); sum = 0; for (i = 1; i <= k; i++) { sum = sum * 2 + 1; if (sum >= n) break; } if (sum >= n) a0 = 1; else a0 = n / sum + (n % 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
#!/usr/bin/env python from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip else: _str = str str = lambda x=b"": x if type(x) ...
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; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; const long long INF = 1LL << 60; const int INT_INF = 1000000000; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; void solve() { int n, k; cin >> n >> k; if (n < k * 1LL * (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
// Change Of Plans BABY.... Change Of Plans // import java.io.*; import java.util.*; import static java.lang.Math.*; public class nProblemsKdays { static void MainSolution() { long n=nl();long m=n; k=ni(); long temp=(k*(k+1))/2; if(n<temp){ pl("NO");return; } ...
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 = map(int, input().split()) base = k * (k + 1) // 2 if n < base: print('NO') exit(0) l = [i + 1 + (n - base) // k for i in range(k)] rem = (n - base) % k if (n - base) // k == 0 and rem != 0 and rem == k - 1: if k in (2, 3): print('NO') exit(0) else: l[-1] += 2 for...
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; int64_t n, k, i; int main() { cin >> n >> k; n -= (k + 1) * k / 2; if (n < 0 || n == k - 1 && k < 4 && k > 1) return cout << "NO", 0; cout << "YES\n"; for (; i < k; i++) cout << i + 1 + n / k + (i > k - n % k) + (n % k && i == 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 n, k, a, f[(int)1e5 + 10]; int low, high; int main() { scanf("%d %d", &n, &k); if (k > 30) low = 1; else { low = n / ((1 << k) - 1); } high = 1.0 * n / k - 1.0 * (k - 1) / 2; if (high < low) printf("NO\n"); else { a = high - 1; for (int...
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 codeforces { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); long n = scan.nextLong(); int k = scan.nextInt(); long a[] = new long[k]; long sum = 0; for (int i = 0; ...
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 main() { long long n, k; scanf("%lld %lld", &n, &k); long long s1 = k * (k + 1) / 2; long long s2 = 0; long long j = 1; long long a[k + 5]; for (long long i = 1; i < k + 1; i++) { s2 += j; j *= 2; } if (s1 > n) { cout << "NO"; 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; const int N = 1e5 + 5; int n, k; long long sum(int u) { return 1LL * u * (u + 1) / 2; } double sumb(int u) { return pow(2.0, u) - 1; } int a[N]; int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= k; i++) { int rep = max(a[i - 1] + 1, (int)ceil((double)n / sumb...
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> inline int in(); inline void wr(int); const int N = (int)1e5 + 5; int a[N]; int main(int argc, char** argv) { register int n = in(), k = in(); register long long L = (k + 1ll) * 1ll * k / 2ll; if (n < L) { puts("NO"); return 0; } n -= L; register int m = n / k; n %= k; f...
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.Scanner; public class D_555 { public static void main(String[] args) { Scanner in = new Scanner(System.in); long n = in.nextLong(); int k = in.nextInt(); //impossible cases //During each day he has to solve at least one problem and one more than the previou...
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.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long n = scanner.nextInt(); int m = scanner.nextInt(); long[] a = new long[m + 1]; long[] b = new long[m + 1]; b[1] = 1; for (i...
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(a): for x, y in zip(a[:-1], a[1:]): if x >= y or y > 2*x: return False return True def solve(n, k): if n < k*(k+1) // 2: return 'NO', None ans = list(range(1, k+1)) plus = n - sum(ans) add = plus // k r = plus % k for i in 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; int n, k, a[100005]; int main() { int i, j; scanf("%d%d", &n, &k); long long tmp = (long long)(1 + k) * k / 2; if (n < tmp) { printf("NO"); return 0; } int res, t; res = n - tmp; t = res / k; for (i = 0; i < k; ++i) a[i] = i + 1 + t; res %= 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 maxn = 1e6 + 9; long long n, k; long long a[maxn]; int main() { cin >> n >> k; long long ret(0); for (long long i = 1; i <= k; ++i) a[i] = i, ret += a[i]; if (ret > n) { puts("NO"); return 0; } long long tmp(n - ret); if (tmp >= 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 java.util.Scanner; public class D { @SuppressWarnings("resource") public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); long n = sc.nextInt(); long k = sc.nextInt(); if ( n * 2 < k * (k + 1) ) { System.out.println("NO"); System.exit...
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 n; int k; long long a[100004]; int main() { scanf("%lld%d", &n, &k); for (int i = 1; i <= k; i++) a[i] = i; long long sum = ((1LL + k) * k) >> 1; if (n < sum) return puts("NO"), 0; long long p = n / sum, r = n % sum; for (int i = 1; i <= k; i++) a[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
#include <bits/stdc++.h> using namespace std; long long a[200010]; long long n, k, sum, x, y; signed main() { cin >> n >> k; for (long long i = 1; i <= k; i++) a[i] = i, sum += i; if (sum > n) { puts("NO"); return 0; } x = (n - sum) / k, y = n - sum - x * k; while (y) { for (long long i = k; 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.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { // br = new BufferedReader(new FileReader(new File("input.txt"))); // out = new PrintWriter(new File("output.txt")); int nasral = 1; for (int JOPA = 0; JOPA < nasral;...
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 main(): global chickens #print = out.append ''' Cook your dish here! ''' n, k = get_list() li = [i+1 for i in range(k)] sm = sum(li) for i in range(k): inc = (n - sm)//(k-i) if i>0: li[i] = li[i-1]+1 if inc>0 and (i==0 or inc+li[i]<=2*li[i-1]): sm += i...
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
n, k = [int(x) for x in input().split()] a = [i for i in range(1, k+1)] s = (k*(k+1))//2 p = 0 if n == s: p = 0 elif n > s: if n - s == k: p = 0 for i in range(k): a[i] += 1 elif n - s > k: d = (n - s) // k for i in range(k): a[i] += d p = (n-s...
PYTHON3