-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDCEPC402.cpp
More file actions
42 lines (41 loc) · 1.48 KB
/
DCEPC402.cpp
File metadata and controls
42 lines (41 loc) · 1.48 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
#include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int t;
scanf("%d",&t);
while(t--){
int n,cntr=0;
scanf("%d",&n);
if(n<=22&&n!=3&&n!=6&&n!=9&&n!=11&&n!=12&&n!=14&&n!=15&&n!=17&&n!=18&&n!=20&&n!=21){printf("NO\n");continue;}
int temp=1000000;
if(n>22){
cntr=n/10;
temp=cntr*11;
int flag=1;
while(flag){
if(temp>n){temp-=11;cntr--;}
else flag=0;
}
flag=1;
while(flag){
int temp2=n-temp;
int a=temp2/3;
float f=temp2/3.0;
if(ceil(f)-f==0){printf("%d\n",cntr+a);flag=0;}
else {temp-=11;cntr--;}
}
}
else{
for(int i=0;11*i<=n;i++){
for(int j=0;i*11+j*3<=n;j++){
if(i*11+j*3==n&& temp>i+j)temp=i+j;
}
}
if(temp==1000000)printf("NO\n");
else printf("%d\n",temp);
}
}
return 0;
}