-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path305.cpp
More file actions
55 lines (49 loc) · 1.02 KB
/
305.cpp
File metadata and controls
55 lines (49 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
queue<int> q;
int arr[20];
int chck(int k){
int fl = 0;
while(!q.empty()){
int u = q.front();
q.pop();
if(u>k) fl = 1;
}
if(fl==1) return -1;
return 1;
}
int main(){
for(int k=1;k<14;k++){
for(int i=1;i<=2*k;i++) q.push(i);
//int l = q.size();
//cout<<l<<endl;
for(int j = 1;;j++){
for(int i=1;i<=2*k;i++) q.push(i);
int cnt = 0;
while(q.size()>k){
int u = q.front();
q.pop();
cnt++;
if(cnt==j) {
cnt = 0;
}
else
q.push(u);
}
int flag = chck(k);
if(flag==1){
cout<<j<<endl;
arr[k] = j;
break;
}
}
}
int k;
while(cin>>k){
if(k==0)
cout<<arr[k]<<endl;
}
}