Advertisement
wojiaocbj

BE

Jun 11th, 2022
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. typedef long long LL;
  3. int main(){
  4.     LL a[256] = { 0 };
  5.     int n, i;
  6.     scanf("%d", &n);
  7.     for(i = 0; i < n; i++){
  8.         scanf("%lld", a + i);
  9.     }
  10.     int flag1 = 1, flag2 = 1, times = 0, fin = 0;
  11.     while(flag1 && flag2){
  12.         flag1 = 0; flag2 = 0;
  13.         for(i = 0; i < n; i++){
  14.             if(a[i]){
  15.                 a[i] >>= 1;
  16.                 if(a[i]){
  17.                     flag1 = 1;//need to continue
  18.                 }
  19.                 else{
  20.                     flag2 = 1;//able to continue
  21.                 }
  22.             }
  23.         }
  24.         times += 1;
  25.     }
  26.     printf("%d\n", times);
  27.     for(i = 0; i < n; i++){
  28.         if(a[i]){
  29.             fin = 1;
  30.         }
  31.     }
  32.     puts(fin ? "Some number left..." : "Clear!");
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement