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; cout << ((n-k)%(k-1)==0 ? (n-k)/(k-1)+1 : (n-k)/(k-1)+2)<<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 Scanner sc = new Scanner(System.in); public static void main(String[] args){ //A /* String s = sc.next(); int ans = 0; for(int i = 0 ; i < 4 ; i++){ if(s.charAt(i) == '+') ans++; else ans--; } System.out.println(ans); */ //B ...
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-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) - 1 for i in input().split()] 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=[int(s) for s 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
#include <bits/stdc++.h> using namespace std; int main(void){ 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
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(); for(int i = 0; i < N; i++) { scan.nextInt(); } scan.close(); int t = 0; if((N - 1) % (K - 1) == 0) { t = (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
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); // 2 <= K <= N final int K = sc.nextInt(); int[] a = new int[N]; for (int i = 0; i < a.length; i++) { a[i] = sc.nextInt(); } // どこに1があってもAi間の境界の数(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
#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+=1; 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
n,k,*_=map(int,open(0).read().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.Scanner; class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(),k=sc.nextInt(); int m=-1; for(int i=0;i<n;i++)if(sc.nextInt()==1)m=i; System.out.println((n-2)/(k-1)+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 a[(int)1e5+1],n,k; int main(){ cin>>n>>k; for(int i=1;i<=n;++i)cin>>a[i]; int ans=(n-1+k-2)/(k-1); cout<<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.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 a[] = new int[N]; for(int i = 0;i<N;i++){ a[i] = scan.nextInt(); } if((N-1)%(K-1) == 0){ 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
#include <bits/stdc++.h> using namespace std; int main(){ int n,k,ans=0;cin>>n>>k; while(k+ans*(k-1)<n) ans++; cout<<ans+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, 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
import java.io.File; import java.io.IOException; import java.util.*; import java.util.Map.Entry; public class Main{ public static void main(String[] args) throws IOException{ //File file = new File("input.txt"); //Scanner in = new Scanner(file); Scanner in = new Scanner(System.in); int N = in.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; import java.util.Arrays; public class Main { public static void main(String[] args) { new Main().solve(); } void solve() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] A = new int[N]; for (...
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 = list(map(int,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
import java.util.Scanner; /** * Copyright © 2018 Chris. All rights reserved. * * @author Chris * 2018/6/23 11:55 * @see meituan.n2018.Bturn */ public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = 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 <iostream> 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
#include <iostream> #include <algorithm> #include <cmath> using namespace std; int main(){ int n, k; cin >> n >> k; cout << ceil((n-1)*1.0/(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
#include <iostream> using namespace std; int d(int x, int y) { return (x+y-1)/y; } int main() { int N, K; cin >> N >> K; cout << d(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
N, K = map(int, raw_input().split()) if N == K: print 1 elif (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 { @SuppressWarnings("resource") public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n=scanner.nextInt(); int k=scanner.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) { a[i]=scanner.nextInt(); } int cnt=2; for(int ...
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; using pp=pair<int,int>; using ll=long long; int main() { int N, K; cin >> N >> K; N-=2; K--; 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; int res=((n-2)/(k-1))+1; 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.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int ans = ( (N-1) + (K-1) - 1 ) / (K - 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
N,K=map(int,input().split()) A=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
from math import ceil N, K = map(int,input().split()) _ = input() 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
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()); 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.Scanner; 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++) sc.nextInt(); System.out.println((N-1+K-2)/(K-1)); } public static int gcd(int a, int b) { return a%b==0 ? b : ...
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.ArrayList; import java.util.List; 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(); List<Integer> aList = new ArrayList<>(); for (int i = 0; i < N; i++) { aList.add(sc.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 math n,k = map(int,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
n,k = map(int,input().split()) input() 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
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int k = scanner.nextInt(); scanner.nextLine(); scanner.nextLine(); int m = (int)Math.ceil(((double)(n-1))/(k-1)); System.out.println(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<bits/stdc++.h> #define rep(i,a,n) for(int i=a;i<n;i++) using namespace std; int main(){ int n,k; cin>>n>>k; cout<<(n-1)/(k-1)+((n-1)%(k-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=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
#include <iostream> int main( void ) { int n, k; std::cin >> n >> k; std::cout << 1 + ( n - k ) / ( k - 1 ) + ( ( n - k ) % ( k - 1 ) ? 1 : 0 ) << 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
#include <bits/stdc++.h> using namespace std; int main() { int N,K; cin >> N >> K; int o = (N + K - 3) / (K - 1); cout << o << 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; import java.math.*; import java.math.*; 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 = sc.nextInt(); // 文字列の入力 //String s = sc.next(); //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()) 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
// C - Minimization #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
N,K = map(int,input().split()) cnt = 1 while N > K + (K-1)*(cnt-1): cnt += 1 print(cnt)
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(final String[] args) { final Scanner scanner = new Scanner(System.in); final int n = scanner.nextInt(); final int k = scanner.nextInt(); System.out.println((n - 2) / (k - 1) + 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()) A=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
#include <iostream> #include <math.h> using namespace std; int main(){ int N, K; cin >> N; cin >> K; cout << ceil((float)(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; 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
#include <bits/stdc++.h> using namespace std; int main() { int n,k; scanf("%d %d",&n,&k); printf("%d\n",(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 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(); for(int i = 0; i < n; i++) { int s = sc.nextInt(); } int ans = (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.Scanner; public class Main{ public static void main(String args[]) { Scanner scn = new Scanner(System.in); int N = scn.nextInt(), K = scn.nextInt(); System.out.println((N-2)/(K-1) + 1); scn.close(); } }
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,a,count=0; cin>>N>>K; count += (N-K+K-2)/(K-1) + 1; 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 ; cout << 1+(n-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
#101_C N,K=map(int,input().split()) A=input() 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 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()) N-=K count=1 while N>0: N-=K-1 count+=1 print (count)
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 sc=new Scanner(System.in); int N=sc.nextInt(); int K=sc.nextInt(); int ichikan=0; int kaisu=1; int[] waku=new int[N]; for(int i=0; i<N; i++) { waku[i]=sc.nextInt(); if(waku[i]==0) { ichikan=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
N, K = map(int,input().split()) ans = -(-(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
n,k=map(int,input().split());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()) cnt=1 n-=k cnt+=(n+k-2)//(k-1) print(cnt)
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--; k--; cout << (n+k-1) / k << 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,k = map(int,input().split()) print((n-1)//(k-1) + ((n-1)%(k-1) > 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
N,K=map(int,input().split()) input() print((N+K-3)//~-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 math n,k = map(int,input().split()) s = 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
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 + 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 math N,K=map(int,input().split()) input() print(math.ceil((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
N, K, *a = map(int, open(0).read().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
import java.util.*; public class Main{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int k = scan.nextInt(); int count = 0; for (int i=0;i<n;i++){ int t = scan.nextInt(); if (t == 1){ count = i+1; break; ...
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 << 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
import java.util.*; import java.lang.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int n = 0; int a = (N-K)/(K-1); if ((N-K)%(K-1) == 0) { n = 1 + 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(); sc.nextLine(); String[] y = sc.nextLine().split(" "); int[] x = new int[y.length]; int min = Intege...
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); String[] S = sc.nextLine().split(" "); int N = Integer.parseInt(S[0]); int K = Integer.parseInt(S[1]); int ans = 0; ans = (N-1)/(K-1); if((N-1)%(K-1) != 0){ 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; cin >> n >> k; int res = 1 + (n - k + k - 2) / (k - 1); cout << res << "\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 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 temp = N; int count = 0; while(temp > 0) { if (count == 0) { temp -= 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.*; public class Main { Scanner sc = new Scanner(System.in); int MOD = (int)1e9 + 7; public static void main(String[] args) { new Main().run(); } void run() { int n = sc.nextInt(); int m = sc.nextInt(); int[] arr = new int[n]; int pos = 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(" ")) A=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> int main(){ long long N,K; std::cin>>N>>K; std::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
#include<bits/stdc++.h> using namespace std; int main(){ int N, K, t = 0; cin >> N >> K; while(K+(K-1)*(t++)<N); cout << t << 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=(int(i) for i in input().split(" ")) A=input() print(1-((K-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 <iostream> using namespace std; int main(void){ int n,k,ans=0; cin>>n>>k; ans+=1; ans+=(n-k)/(k-1); if((n-k)%(k-1)!=0)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
public class Main { private static java.util.Scanner sc = new java.util.Scanner(System.in); public static void main(String[] args) { int n=sc.nextInt(); double k=sc.nextDouble(); System.out.println((int)Math.ceil((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; cout << (N-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
#include <iostream> using namespace std; int main() { long long int n, k, sum; cin >> n >> k; sum = (n-1)/(k-1); if( (n-1)%(k-1) != 0 ) sum++; cout << sum; }
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; string s; getline(cin, s); 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()) ans = ((N-1)//(K-1) + (1 if (N-1)%(K-1) else 0)) 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
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner stdin = new Scanner(System.in); int n = stdin.nextInt(); int k = stdin.nextInt(); int memo=0; int val=10000000; int ans=10000000; int x[] = new int[n]; for(int i=0;i<n;i++) { x...
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 - 3)/(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
#include<stdio.h> int main(){ int n,k,i,a,ans; scanf("%d%d",&n,&k); for(i=0;i<n;i++) scanf("%d",&a); ans=(n-1)/(k-1); if((n-1)%(k-1)!=0) ans++; printf("%d\n",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
#include<bits/stdc++.h> using namespace std; int main(){ int N,K,ans=1; cin>>N>>K; N=N-K; K--; if(N%K==0) ans=ans+N/K; else ans=ans+1+N/K; cout<<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
#include <bits/stdc++.h> using namespace std; int n, k; int main() { cin >> n >> k; if (k==2) { cout << n-1 << endl; } else { cout << n/(k-1) + (n%(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 <iostream> using namespace std; int main(){ int n,k,ans; cin>>n>>k; ans=(n-1)/(k-1); if( (n-1)%(k-1) != 0)ans++; 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 in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); } int...
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 { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int N = sc.nextInt(); int K = sc.nextInt(); System.out.println(((N-1) + (K - 2)) / (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 <cstdio> int main(){ int n,k; scanf("%d %d",&n,&k);printf("%d",(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
#include <bits/stdc++.h> using namespace std;int main(){int N,K;cin>>N>>K;cout<<(N-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.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] str = br.readLine().split(" "); int n = Integer.parseInt(str[0]); int k = Integer.parseInt(str[1]); str = br.readLine(...
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 = Integer.parseInt(sc.next()); int k = Integer.parseInt(sc.next()); int[] a = new int[n]; for (int i = 0; i < n; i++) { int tmp = 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
N, K = map(int, input().split()) A = 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
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n,k; cin >> n >> k; cout << (n+k-3)/(k-1) << endl; return 0; }
CPP