Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int n = 500000000, i;
- int arr[100000];
- void swap(int* a, int* b) {
- int t = *a;
- *a = *b;
- *b = t;
- }
- int partition (int arr[], int low, int high) {
- int pivot = arr[high];
- int i = (low - 1);
- for (int j = low; j <= high- 1; j++) {
- if (arr[j] <= pivot) {
- i++;
- swap(&arr[i], &arr[j]);
- }
- }
- swap(&arr[i + 1], &arr[high]);
- return (i + 1);
- }
- void qSort(int arr[], int l, int h) {
- if (l < h) {
- int pi = partition(arr, l, h);
- qSort(arr, l, pi - 1);
- qSort(arr, pi + 1, h);
- }
- }
- void sJo(int div){
- arr[i++] = div;
- if(div > n){
- return;
- }else{
- return sJo(div*10+7), sJo(div*10+8);
- }
- }
- int main(){
- int tc;
- sJo(7);
- sJo(8);
- qSort(arr, 0, 1021);
- scanf("%d",&tc);
- for(int i=1;i<=tc;i++){
- int num;
- bool flag = false;
- scanf("%d",&num);
- if(num==7 || num==8){
- printf("Case #%d: YES\n", i);
- continue;
- }
- for(int j=0;j<1022;j++){
- if(arr[j]>num/2){
- flag = true;
- break;
- }
- if(num%arr[j]==0){
- printf("Case #%d: YES\n", i);
- break;
- }
- }
- if(flag){
- printf("Case #%d: NO\n", i);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement