結果

問題 No.381 名声値を稼ごう Extra
ユーザー kuuso1kuuso1
提出日時 2016-06-18 22:09:07
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,572 bytes
コンパイル時間 949 ms
コンパイル使用メモリ 112,484 KB
実行使用メモリ 56,216 KB
最終ジャッジ日時 2024-04-18 02:56:56
合計ジャッジ時間 10,341 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
26,888 KB
testcase_01 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using BI = System.Numerics.BigInteger;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int W = 100;
		BI carry = 1;
		for(int i=0;i<W;i++){
			carry *= 10;
		}
		
		String pad = "";
		while((S.Length + pad.Length)%W != 0)pad += "0";
		S = pad + S;
		int N = S.Length;
		int NN = N/W;
		BI[] dp = new BI[NN];
		for(int i=0;i<NN;i++){
			dp[i] = BI.Parse(S.Substring(i*W,W));
		}
//Console.WriteLine("{0} {1}",S,String.Join(" ",dp));		
		int t = 0;
		int cnt = 0;
		while(true){
			for(int i=t;i<NN-1;i++){
				if( (dp[i] & 1) == 1 )dp[i+1] += carry;
				dp[i] >>= 1;
			}
			if((dp[NN-1] & 1 ) == 1)cnt++;
			dp[NN-1] >>= 1;
			if(dp[t] == 0)t++;
			if(t==NN)break;
		}
		
		Console.WriteLine(cnt);
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0