Advertisement
wojiaocbj

k

Jun 9th, 2022
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. char cur[1044] = {0};
  3. int main(){
  4.     int n,rd,i;
  5.     while(~scanf("%d",&rd)){
  6.         cur[rd]++;
  7.         for(i = rd;i <= 1024;i++){
  8.             if(cur[i] > 1){
  9.                 cur[i] &= 1;
  10.                 cur[i + 1]++;
  11.             }
  12.         }
  13.         for(i = 1024;i >= 0;i--){
  14.             if(cur[i]){
  15.                 printf("%d\n",i);
  16.                 break;
  17.             }
  18.         }
  19.     }
  20.     for(i = 1024;i >= 0;i--){
  21.         if(cur[i]){
  22.             printf("%d ",i);
  23.         }
  24.     }
  25.     putchar('\n');
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement