wojiaocbj

Untitled

Jun 6th, 2022
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. /*
  2.  Author: 曹北健
  3.  Result: AC Submission_id: 4505056
  4.  Created at: Tue Jun 07 2022 11:44:00 GMT+0800 (China Standard Time)
  5.  Problem_id: 5793   Time: 10    Memory: 1740
  6. */
  7.  
  8. #include <stdio.h>
  9. char cur[1044] = {0};
  10. int main(){
  11.     int n,rd,i;
  12.     while(~scanf("%d",&rd)){
  13.         cur[rd]++;
  14.         for(i = rd;i <= 1024;i++){
  15.             if(cur[i] > 1){
  16.                 cur[i] &= 1;
  17.                 cur[i + 1]++;
  18.             }
  19.         }
  20.         for(i = 1024;i >= 0;i--){
  21.             if(cur[i]){
  22.                 printf("%d\n",i);
  23.                 break;
  24.             }
  25.         }
  26.     }
  27.     for(i = 1024;i >= 0;i--){
  28.         if(cur[i]){
  29.             printf("%d ",i);
  30.         }
  31.     }
  32.     putchar('\n');
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment