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
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k = map(int,input().split()) A = input() ans = 1 + -(-(n-k)//(k-1)) print(ans)
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k = map(int, input().split()) a = list(map(int, input().split())) print(((n-1)+(k-2))//(k-1))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<bits/stdc++.h> using namespace std; int main(){ int n,k; cin>>n >>k; cout<<(n+k-3)/(k-1)<<endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n,k; cin>>n>>k; n--,k--; cout<<(n+k-1)/k<<endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
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(); int A[] = new int[N]; for(int i = 0; i < N; i++) { A[i] = sc.nextInt(); } System.out.println((int)Math.ceil((double)(N - 1) / (double)(K - ...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); for (int i = 0; i < n; ++i) in.nextInt(); int ans = 0; int cur = 0; ...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> #include <algorithm> using namespace std; int main() { int n,k; cin>>n>>k; int m=n,x,y; cout<<((n-1)+(k-2))/(k-1)<<endl; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
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(); int ans = (int) (Math.ceil((n-k)/(double)(k-1))+1); System.out.println(ans); } }
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<iostream> using namespace std; int main() { int n,k,a[1<<17];cin>>n>>k; for(int i=0;i<n;cin>>a[i++]); cout<<--n/--k+(n%k>0)<<endl; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
from math import ceil n,k = map(int,input().split(" ")) print(ceil((n - 1) / (k - 1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
N,M=map(int,input().split()) M-=1 N-=1 x=N//M if N%M!=0: x+=1 print(x)
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k = map(int, raw_input().split()) print -(-(n-k)//(k-1)) + 1
PYTHON
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<iostream> using namespace std; int main(){ int N,K; cin>>N>>K; N--; K--; int res=(N+K-1)/K; cout<<res<<endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); //test cases int n = in.nextInt(); int k = in.nextInt(); //array input //int N = in.nextInt(); int[] arr = new int[n...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { int n = sc.nextInt(); int k = sc.nextInt(); Integer a[] = new Integer[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } Arrays.s...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<iostream> using namespace std; int main(){ int n,k; cin>>n>>k; int a[100009]; for(int i=0;i<n;i++) cin>>a[i]; cout<<(n-2)/(k-1)+1<<endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import math N, K = map(int, input().split()) nums = input() print(math.ceil((N - 1) / (K - 1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<iostream> using namespace std; int main(){ int n, k; cin>>n>>k; cout<<((k!=1)?((n-2)/(k-1)+1):n)<<endl; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<bits/stdc++.h> signed main(){ int n,m; std:: cin >> n >> m; std:: cout << (n-m)/(m-1) + ((n-m)%(m-1)?1:0)+1 << std:: endl; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(), len = sc.nextInt(), one = 0; int[] n = new int[num]; for(int i = 0; i < num; i++) { n[i] = sc.nextInt(); if(n[i] == 1)one = i; } int s = one, t = num-1...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n, k = map(int, input().split()) d = k - 1 print((n + d - 2) // d)
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner stdIn=new Scanner(System.in); int N=stdIn.nextInt(); int K=stdIn.nextInt(); int z=0,y=0,ans=0; while(z<N){ y=stdIn.nextInt(); if(y==1){ y=z; break; } z++; }z=0; ans+=(y-1)/(K-1); ans+=(N-y)...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k = map(int , raw_input().split()) c = n - k p = k - 1 print 1 + (c + p-1)/p
PYTHON
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; cout << (n - 1 + (k - 2)) / (k - 1) << endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
N,K=map(int,input().split()) A = list(map(int,input().split())) print(-(-(len(A)-1)//(K-1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> using namespace std; int main(){ int n, k; cin >> n >> k; cout << ceil((n-1.0)/(k-1.0)) << endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
N,K=map(int,input().split()) A=list(map(int,input().split())) print((N-1+(K-2))//(K-1))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> using namespace std; int main(){ int n, k; cin >> n >> k; int ans = 0; while(n > ans*(k-1)+1) ans++; cout << ans << endl; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
N, K = map(int, input().split()) print(((N - 1) + (K - 1) - 1) // (K - 1))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k = map(int, raw_input().split()) a = map(int, raw_input().split()) p = a.index(1) if (n-1) % (k-1) == 0: print (n-1) / (k-1) else: print (n-1) / (k-1) + 1
PYTHON
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int ans = 0; if ((n-1) % (k-1) == 0) { ans = (n-1) / (k-1); } else { ans =...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
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(); int a = 0; for(int i = 0;i < N;i++){ int b = sc.nextInt(); if(b == 1) a = i; } ...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { try (Scanner scanner = new Scanner(System.in)) { int n = scanner.nextInt(), k = scanner.nextInt(); IntStream.range(0, n).forEach(i -> scanner.nextInt()); System.out.println((n + k - 3)...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <iostream> int main() { int n, k; std::cin >> n >> k; std::cout << (n - 1 + k - 2) / (k - 1); return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import math n, k = map(int, input().split()) A = input() print(math.ceil((n-1) / (k-1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n, k = list(map(int, input().split(" "))) print((n - 2) // (k - 1) + 1)
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k=[int(i) for i in input().split()] print(-((-n+1)//(k-1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import sys import math imp = raw_input().strip().split(" ") a = raw_input().strip().split(" ") N = int(imp[0]) K = int(imp[1]) cnt = 0 while N > K : N = N - K + 1 cnt += 1 print(str(cnt+1))
PYTHON
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import math N, K = map(int, input().split()) print( 1 + math.ceil((N-K) / (K-1)) )
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { new Main().run(); } public void run() { try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) { String[] line...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
N,K = [int(i) for i in input().split()] print(-(-(N-1)//(K-1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); int k = stdIn.nextInt(); int[] a = new int[n]; int t = n / (k-1); int r = n % (k-1); int s; s = (n == k) ? 1 : ((r == 0 || r == 1) ? t : t + 1); if (k == 2...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } if...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int[] arr = new int[n]; int minPoint = 0; for(int i = 0; i < n; i++) { arr[i] = sc.next...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <iostream> using namespace std; int main(){ int n, k; cin >> n >> k; cout << ((n-1)%(k-1)==0 ? (n-1)/(k-1) : (n-1)/(k-1) + 1); return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
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(); for (int i = 0; i < N; i++) { int a = sc.nextInt(); } int ans = (N - 1) / (K - 1); if ((N - 1) % (K - 1) != 0) { an...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n, k = map(int, input().split()) a = (list)(map(int, input().split())) print(-(-(n-1)//(k-1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
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(); System.out.println((n + k - 3) / (k - 1)); } }
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <iostream> using namespace std; int main() { int N, K; cin >> N >> K; long P=(N+K-3)/(K-1); cout << P << endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> using namespace std; int main(){ int N,K; cin>>N>>K; int a; for(int i=0;i<N;i++){ cin>>a; } cout<<(N+K-3)/(K-1)<<endl; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<bits/stdc++.h> using namespace std; long K, N; long A; long id; int main(){ scanf("%ld%ld", &N, &K); printf("%ld\n", (long)ceil((double)(N-K)/(K-1))+1); }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<bits/stdc++.h> using namespace std; int main() { int n , k; cin >> n >> k; n -= k; double ans = ceil (1.0 * n / (k - 1) ); cout << (int) ans + 1 << endl; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.next()); int k = Integer.parseInt(sc.next()); for(int i = 1;;i++){ n = n-k; if(n <= 0){...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k=map(int,input().split()) print((n-1+k-2)//(k-1))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; cout << (n-1) / (k-1) + ((n-1)%(k-1)>0) << endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#coding: utf-8 n,k = map(int,raw_input().split()) s = raw_input() if (n-1)%(k-1) == 0: print (n-1)/(k-1) else: print (n-1)/(k-1)+1
PYTHON
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import math print((lambda x:math.ceil((int(x[0])-1)/(int(x[1])-1)))(input().split()))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> #define int long long using namespace std; float N,K; signed main(){ cin >> N >> K; cout << (int)ceil((N-1)/(K-1)) << endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> using namespace std; int main(){ int n,k; cin >> n >> k; cout << (n-2) / (k-1) + 1 << endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k=map(int,input().split());input() print(-(-~-n//~-k))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
N,K=map(int,input().split()) _=input() print((N-2)//(K-1)+1)
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k=map(int,input().split());print((n-1+k-1-1)//(k-1))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int a[] = new int[N]; for (int i = 0; i < N; i++) { a[i] = sc.nextInt(); } System.out.println((int)Math.ceil((double)(N-1)/(K-1))); ...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n, k = map(int, input().split()) res = - ((1 - n) // (k-1)) print(res)
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < A.length; i++) { A[i] = sc.nextInt(); } ...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import math n, k = map(lambda x : int(x), input().split()) print(math.ceil((n - 1) / (k - 1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include "bits/stdc++.h" typedef long long ll; using namespace std; int main() { int n, k; cin >> n >> k; cout << (n - 1+k-2) / (k - 1) ; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
a,b=map(int,input().split()) print(int((a-1)/(b-1)) if (a-1)%(b-1)==0 else (a-1)//(b-1)+1)
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
// Java implementation of Kosaraju's algorithm to print all SCCs import java.io.*; import java.util.*; import java.util.LinkedList; // This class represents a directed graph using adjacency list // representation public class Main { // Driver method public static void main(String args[]) { Scanner in=n...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k=map(int,input().split());print(0--~-n//~-k)
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.*; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] A = new int[N]; for(int i=0; i<N; i++){ A[i] = sc.nextInt(); } if((N-1)%(K-1)==0){ ...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import math n,k = map(int,input().split()) input() print(math.ceil((n-1)/float(k-1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
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(); int[] A = new int[N]; for (int i = 0; i < N; i++) { A[i] = sc.nextInt(); } sc.close(); System.out.println((in...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
def solve(n, k, a): return (n+k-3) / (k-1) assert solve(4, 3, [2,3,1,4]) == 2 assert solve(3, 3, [1,2,3]) == 1 assert solve(8, 3, [7,3,1,8,4,6,2,5]) == 4 n, k = map(int, raw_input().split()) a = map(int, raw_input().split()) print solve(n, k, a)
PYTHON
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k=map(int,input().split()) a=list(map(int,input().split())) print(-(-(n-k)//(k-1))+1)
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.*; import static java.lang.System.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] a = new int[N]; for (int i = 0; i < N; i++) a[i] = sc.nextInt(); ...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include "bits/stdc++.h" typedef long long ll; using namespace std; int main() { int n, k; cin >> n >> k; cout << (n - 2) / (k - 1) + 1; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) int main(){ int n,k;cin>>n>>k; cout << ((n - 1) + (k - 2)) / (k - 1) << endl; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().solve(new Scanner(System.in)); } public void solve(Scanner sc) { int n = Integer.parseInt(sc.next()); int k = Integer.parseInt(sc.next()); int answer = 1; int deltaN = n; int deletableNum = k-1; w...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n, k = map(int, (input().split())) print(1 - (-(n - k) // (k - 1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { int n; int k; String[] a; Scanner sc = new Scanner(System.in); n = sc.nextInt(); k = sc.nextInt(); sc.nextLine(); a = sc.nextLine().split(" "); int one =...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k=map(int,input().split()) a=len(list(map(int,input().split()))) print((n+k-3)//(k-1))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> using namespace std; int main(){ int n,k; cin>>n>>k; n--; int ans=0; while(n>0){ n = n-k+1; ans++; } cout<<ans; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<bits/stdc++.h> using namespace std; int main(){ int n,k; cin>>n>>k; int s=0; while(n>k+(k-1)*(s-1)){ s++; } cout<<s<<endl; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[]args) { try(Scanner scan = new Scanner(System.in)){ int N = scan.nextInt(); int K = scan.nextInt(); int []A = new int[N]; int onenum = 0; long goukei = 0; for(int i = 0;i<N;i++) { A[i] = scan.nextInt(); if(A...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n, k = map(int, input().split()) print((n - 2) // (k - 1) + 1)
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; cout << ceil((double)(N-1)/(K-1)) << endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
a,b = map(int,input().split()) c = input() print((a+b-3)//(b-1))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
// ABC101C - Minimization #include <cstdio> int main() { int N, K; scanf("%d%d", &N, &K); printf("%d\n", (N - 2)/(K - 1) + 1); return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int N = scanner.nextInt(); int K = scanner.nextInt(); int[] a = new int[N]; for (int i = 0; i < N; i++) { a[i] = s...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<iostream> using namespace std; int main(){ int a,b; cin>>a>>b; a--; b--; cout<<a/b+bool(a%b); return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), k = in.nextInt(); int[] a = new int[n]; for (int j = 0; j < n; j++) { a[j] = in.nextInt(); } System.out.println((int)Math.ceil((n - 1) /...
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include<bits/stdc++.h> using namespace std; int main(){ int n,k,ans; cin >> n >> k; ans=(n-1+k-2)/(k-1); cout << ans << endl; return 0; }
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); sc.nextLine(); sc.nextLine(); int i = 1; while( N > (i * K) - (i - 1)) { i++; } System.out.println(i); } }
JAVA
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import math N, K = map(int, input().split()) input() print(math.ceil((N-1)/(K-1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n,k=map(int,input().split());print((n+k-3)//(k-1))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
N,K=map(int,input().split()) A=list(map(int,input().split())) print(-((1-N)//(K-1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
#include <bits/stdc++.h> using namespace std; int main(){int a,b; cin>>a>>b; cout<<(a-2)/(b-1)+1;}
CPP
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
n, m = map(int, input().split()) print(-(-(n-1)//(m-1)))
PYTHON3
p03317 AtCoder Beginner Contest 101 - Minimization
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements....
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); if (n == k) { System.out.println(1); } else if (k == 2) { System.out.println(n - 1)...
JAVA