結果

問題 No.381 名声値を稼ごう Extra
コンテスト
ユーザー tagenkan
提出日時 2019-02-25 19:19:32
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
TLE  
実行時間 -
コード長 681 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 201 ms
コンパイル使用メモリ 39,488 KB
最終ジャッジ日時 2026-02-22 02:30:58
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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