結果

問題 No.381 名声値を稼ごう Extra
ユーザー tagenkantagenkan
提出日時 2019-02-25 19:19:32
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 681 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 28,812 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 09:51:18
合計ジャッジ時間 11,260 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char s[1048576];
char a[1048576];

int main()
{
  int alen,i,tmp,c,ans=0;

  if(scanf("%1000001s",s)<1)
    exit(-1);
  if(sscanf(s,"%[0123456789]s",a)<1)
    exit(-1);
  alen=strlen(a);
  if(alen==0)
    exit(-1);
  if(alen==1&&a[0]=='0'){
    printf("0\n");
    return 0;
  }
  for(i=0;i<=((alen-1)>>1);i++){
    tmp=a[i];
    a[i]=a[alen-1-i]-48;
    a[alen-1-i]=tmp-48;
  }
  while(alen>0){
    if(a[alen-1]==1){
      c=1;
      alen--;
    } else {
      c=0;
    }
    for(i=alen-1;i>=0;i--){
      a[i]=10*c+a[i];
      c=a[i]&1;
      a[i]>>=1;        
    }
    ans+=c;
  }
  printf("%d\n",ans);
  return 0;
}

0