結果

問題 No.378 名声値を稼ごう
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-06-22 19:25:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 451 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 59,768 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 00:24:04
合計ジャッジ時間 911 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;

int main(){

	long long N;
	vector<long long> v;
	int notn;
	int maxn;

	cin>>N;

	while(N!=0){
		v.push_back(N);
		N/=2;
	}

	notn=0;
	for(int i=0;i<v.size();i++){
		notn+=v[i];
	}

	maxn=-1;
	for(int i=0;i<v.size();i++){
		int sum=0;
		for(int j=0;j<v.size();j++){
			if(i==j){
				sum+=v[j]*2;
				break;
			}
			else sum+=v[j];
		}
		if(maxn<sum) maxn=sum;
	}

	cout<<maxn-notn<<endl;
}

0