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
#include <bits/stdc++.h> using namespace std; int main(){ int N,K; cin>>N>>K; int kotae=1; N-=K; while(N>0){ kotae++; N-=K-1; } cout<<kotae<<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.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; @SuppressWarnings("unchecked") public class Main { public static void main(String[] args) throws IOException { final String s; final String t; try ( BufferedReader reader = new Buffere...
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) throws Exception { 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((int) M...
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 ans = (N-1)/(K-1); if((N-1)%(K-1)!=0) ans++; cout << ans << "\n"; 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 = input().split() K = int(N[1]) Z = int(N[0]) - K print(math.ceil(Z / (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<iostream> using namespace std; int n,k; int main() { cin>>n>>k; if((n-k)%(k-1)==0) cout<<(n-k)/(k-1)+1; else cout<<(n-k)/(k-1)+2; }
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
def modnotzero(m, n): if m % n != 0: return 1 else: return 0 N, K = map(int, raw_input().split()) A = map(int, raw_input().split()) pos = 0 for i in range(0, N): if A == 1: pos = i left = pos right = N - 1 - pos min = N+1 for i in range(0, K): L = left - i R = right - K + 1 + i if L >= 0 and R >= 0: cnt = L/(...
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 - 1) + ((n - 1) % (k - 1) ? 1 : 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
n,k=map(int,input().split()) a=[int(i) for i in input().split()] x=n-1 y=k-1 print((x+y-1)//y)
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) { int n, k; int [] a; try (Scanner cin = new Scanner(System.in)) { n = cin.nextInt(); k = cin.nextInt(); a = new int[n]; for (int i = 0; i < n; 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.*; 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 - 1) + (k - 1) - 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,m=map(int,input().split()) l=list(map(int,input().split())) print(-(-(len(l)-m)//(m-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 <iostream> #include <string> using namespace std; int main() { int N, K; cin >> N >> K; int ans = ( N - 1 + K - 2 ) / ( K - 1 ); printf("%d",ans); 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) throws Exception { 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); ...
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[n]; for(int i = 0; i < n; i++) cin >> a[i]; 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
print(eval('0--~-'+''.join([i if i!=' 'else'//~-'for i in input()])))
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> int main() { int N, K; std::cin >> N >> K; std::cout << ((N + K - 3) / (K - 1)) << std::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
#!/usr/bin/env python3 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
#include <bits/stdc++.h> using namespace std; int main(){ int n,k; cin>>n>>k; cout<<ceil((double)(n-1)/(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; int main() { int N, K; cin >> N >> K; cout << ceil(double(N-K)/(K-1)+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<cstdio> int updiv(int x,int k) {return x/k+((x%k)?1:0);} int main() { int n,k;scanf("%d%d",&n,&k); printf("%d\n",updiv(n-1,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 java.util.Scanner; public class Main { public static void main(String[] args) { partC101(); } public static void partC101() { Scanner scC = new Scanner(System.in); int N = scC.nextInt(); int K = scC.nextInt(); int[] A = new int[N]; for(int i = 0 ; i < N ; i++) { A[i] = scC.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 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(); int ans = 0; for(int i = 0 ; i < n;) { ans++; i += 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
import math N,K = map(int, input().split()) ans = math.ceil((N-1) / (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
#include <bits/stdc++.h> using namespace std; int main() { int n,k; cin>>n>>k; if((n-1)%(k-1)==0) cout<<(n-1)/(k-1)<<endl; else cout<<(n-1)/(k-1)+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) { // TODO 自動生成されたメソッド・スタブ Scanner input = new Scanner(System.in); String line = input.nextLine(); String[] array = line.split(" "); int N = Integer.parseInt(array[0]); int K = Integer.parseInt(arr...
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, ai; cin >> n >> k; n--; k--; int ans = n / k + (n % k ? 1 : 0); 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
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double n = sc.nextInt(); double k = sc.nextInt(); int times = (int) Math.ceil((n - k) / (k - 1)); System.out.println(times + 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(void){ 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
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(); } 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 <bits/stdc++.h> using namespace std; int main(){ int N,K; cin>>N>>K; 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] nk = br.readLine().split(" "); ...
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()) 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
#include <bits/stdc++.h> using namespace std; int main() { int n,k; cin>>n>>k; cout<<(n+k-3)/(k-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, K = map(int, raw_input().split()) A = map(int, raw_input().split()) res = 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
N, K = map(int, input().split()) A = [int(x) for x in 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, M = map(int, raw_input().split()) a = [] a.append(map(int, raw_input().split())) keylist = range(N) colum = M valuelist = a A = {k: v for k, v in zip(keylist, valuelist)} minkey = min(A, key = A.get) minnum = min(A.values()) sum1 = 0 if minkey%(colum-1) != 0: sum1 = sum1 + (minkey//(colum-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.*; 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(); int count = 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-1)+(1 if (n-1)%(k-1) else 0))
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 << (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
import math n, k = map(int, input().split()) input() 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.util.*; public class Main { public static void main(String[] args) throws Exception { 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
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int K = scan.nextInt(); int p = 0; for(int i = 0; i < N; i++) { int a = scan.nextInt(); if(a == 1) { p = i; } } scan.close(); if(N == 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
#include<bits/stdc++.h> using namespace std; int main(){ int n,k; cin>>n>>k; cout << ( (n-3+k)/(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 math N, K = map(int, input().split(" ")) a = N - 1 b = K - 1 print(math.ceil(a/b))
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(1 if n==k else 1+(n-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
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]; int b = 0; for(int i = 0; i < n; i++) { a[i] = sc.nextInt(); if(a[i] == 1) b = i; } int t...
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; cin>>N>>K; if(N==K) cout<<1<<endl; else cout<<2+(N-K-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
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]; int leftc = 0; int rightc =0; int answer =0; for(int i=0;i<n;i++){ a[i] = sc.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
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 count = 1; int sub = n - k; if (sub % (k - 1) == 0) { count += sub / (k - 1); } else { count += sub / (k - 1) + 1; } System.ou...
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 = Integer.parseInt(sc.next()); int k = Integer.parseInt(sc.next()); int[] a = new int[n]; for(int i = 0; i < n; i++) a[i] = Integer.parseInt(sc.next()); long ans = (long...
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) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] arr = new int[N]; 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
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]; int One=0; for(int i=0;i<N;i++){ A[i] = sc.nextInt(); if(A[i]==1){ One=i; } } System.out.println((...
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 s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); for (int i = 0; i < n; i++) { s.nextInt(); } int num = (n - 1) / (k - 1); if ((n - 1) % (k - 1) != 0) { num++; } System.o...
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 = list(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> typedef long long lint; using namespace std; int n, k; int main() { 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
N, K = map(int, raw_input().split(' ')) raw_input() N = N - K K = K - 1 print (N+K-1)/K + 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
N,K=map(int,input().split()) n=K num=1 while not n>=N: n+=K-1 num+=1 print(num)
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 math S = list(map(int,input().split())) N = S[0] K = S[1] 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> using namespace std; int n, k; int main() { cin >> n >> k; k--, n--; cout << ceil(1.0 * n / 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.io.InputStream; import java.io.PrintStream; import java.util.Scanner; public class Main { InputStream in = System.in; PrintStream out = System.out; public void _main(String[] args) { Scanner sc = new Scanner(in); int N = sc.nextInt(); int K = sc.nextInt(); N -= K; out.println((int) Math.ce...
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+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 <iostream> using namespace std; int main() { int N,K; cin >> N >> K; cout << (((N-1)/(K-1)) + ((N-1)%(K-1)?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
#include <iostream> using namespace std; int main() { int n,k,sum=0; cin >> n >> k; n -= k; sum++; while(n>0){ n-=(k-1); sum++; } cout << sum; 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.io.BufferedReader; import java.io.InputStreamReader; public class Main { /* -------------------------------------------------------------------- main * -------------------------------------------------------------------- */ public static void main(String args[]) throws Exception { // ----- inpu...
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; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(), K = sc.nextInt(); for(int i = 0; i < N; i++) { int A = 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
import java.util.*; public class Main { /* * input : N * K * A1 , A2 .... An * output : 回数 */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); for(int i=0;i<N;i++) { int ai = sc.ne...
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()) A=map(int, raw_input().split()) 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(), k = sc.nextInt(); int ans = 0; for(int i = 0; i < n; i++) { int a = sc.nextInt(); if (a == 1) { int l = i / (k-1) + (i % (k-1) != 0 ? 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
print(eval("-(-~-"+input().replace(" ","//~-")+")"))
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()) print (N-1)/(K-1)+(0 if (N-1)%(K-1) == 0 else 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[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } Sys...
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 a = sc.nextInt(); int b = sc.nextInt(); int c = (a-1)/(b-1); int d = ((a-1)%(b-1)==0) ? 0 : 1; System.out.println((c+d)); } }
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> #include <bits/stdc++.h> using namespace std; int main() { double n, k; cin >> n >> k; cout << ceil((n-k)/(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; int main(){ int n,k; cin>>n>>k; cout<<((n-1)/(k-1)+int((n-1)%(k-1)!=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 = n-1 B = k-1 print((A+(B-1))//B)
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); String[] str = sc.nextLine().split(" "); int n = Integer.parseInt(str[0]); int k = Integer.parseInt(str[1]); // List<String> list = Arrays.asList(sc.nextLine().split(" ")); // 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
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner reader = new Scanner(System.in); int N = reader.nextInt(); int K = reader.nextInt(); int ans = 0; while (N > 1) { N -= K - 1; ans++; } reader.close(); System.out.print(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 <bits/stdc++.h> using namespace std; 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
from math import ceil n, k = map(int, raw_input().split()) #arr = map(int, raw_input().split()) print max(1, int(ceil(float(n-1)/(k-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.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int k = scanner.nextInt(); ArrayList<Integer> a = new ArrayList<>(); for (int i=0;i<n;i++){ scanner.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 java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int answer = 1; int N = sc.nextInt(); int K = sc.nextInt(); int A[] = new int[K]; for(int i=0; i<K; i++){ A[i] = sc.nextInt(); } int x = N-K; if(x<=0) System.out.pri...
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-k+(k-2))/(k-1)+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; class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double N = scanner.nextInt(); double K = scanner.nextInt(); // int[] as = new int[N]; // int index1 = 0; // for (int i = 0; i < N; 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.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); long[] array = new long[n]; for (int i = 0; i < n; i++) { array[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
N, K = map(int, input().split()) arr = 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.Scanner; public class Main { /** * Minimization */ public static void main(String...args) { try (Scanner sc = new Scanner(System.in)) { int n = sc.nextInt(); int k = sc.nextInt(); if ((n - 1) % (k - 1) == 0) { System.out.println((n - 1) / (k - 1)); } else { System.out.prin...
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 = [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
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() { double N,K; cin >> N >> K; double ans = ceil((N-1)/(K-1)); cout << (int)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
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 count = 0; int here = 0; for(int i = 0;i < n;i++){ int a = sc.nextInt(); count++; if(a == 1)here = count; } int ans = 0; int p =...
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
from math import ceil N, K = [int(c) for c in raw_input().split()] A = [int(c) for c in raw_input().split()] print int(ceil((N-1.0)/(K-1.0)))
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 = list(map(int,input().split())) A = 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
n,k=map(int,input().split()) a=[int(x) for x in 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
import java.util.*; public class Main{ public static void main(String[] artgs){ Scanner sc = new Scanner(System.in); String[] arr = sc.nextLine().split(" "); int N = Integer.parseInt(arr[0]); int K = Integer.parseInt(arr[1]); arr = sc.nextLine().split(" "); int[] A = new int[N]; for (int i = 0; i < A.le...
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(); } int count = (int) Math.ceil((double...
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 = new int[N]; for(int i = 0; i < N; i++){ A[i] = sc.nextInt(); } sc.c...
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; int count = 0; cin >> N >> K; N--; K--; while (N > 0) { N -= K; count++; } cout << count << 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<iostream> using namespace std; int main(){ int n,k; cin >> n >> k; n -= 1;k -= 1; if(n%k==0) cout << n/k << endl; else cout << (n/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; int main() { int N, K; cin >> N >> K; cout << (N - 2) / (K - 1) + 1 << endl; return 0; }
CPP