結果

問題 No.381 名声値を稼ごう Extra
ユーザー もるもる
提出日時 2016-07-07 19:47:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 361 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 30,464 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2024-04-21 00:58:27
合計ジャッジ時間 828 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d",&N);
      |         ~~~~~^~~~~~~~~
main.cpp:19:13: warning: ‘S’ may be used uninitialized [-Wmaybe-uninitialized]
   19 |         max = S[0];
      |         ~~~~^~~~~~
main.cpp:11:13: note: ‘S’ declared here
   11 |         int S[100];
      |             ^

ソースコード

diff #

#include <stdio.h>
#include <math.h>

int main(void)
{

	int N;
	scanf("%d",&N);
	int T=N;
	int K=0;
	int S[100];
	while(T!=0)
	{	T=floor(T/2);
		S[K]=N+2*T;
		K++;
		N=N+T;
	}
	int max;
	max = S[0];
    for (int i = 1; i < K; i++) 
    {
        if (max < S[i])
         {
            max = S[i];
        }
    }
    int answer=max-N;
	printf("%d\n",answer);
}
0