結果

問題 No.420 mod2漸化式
ユーザー olphe
提出日時 2016-11-18 21:55:44
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 879 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 53,464 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-26 06:18:07
合計ジャッジ時間 10,854 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 29 WA * 2 TLE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
using namespace std;

const long long int UP = 2147483647;
long long int log_num[32] = { 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435356,536870912,1073741824,2147483648 };
int N;
long long int ans;
int fig;

void search(long long int num,int point ,int cap) {
	if (num > UP)return ;
	if (num == 0) {
		search(1, 1,30);
		if (N == 0) {
			fig++;
		}
		return ;
	}
	if (point < N) {
		if(cap-1+point>=N)search(num * 2, point,cap-1);

		if(cap+point)search(num * 2 + 1, point + 1,cap-1);
	}
	else if (point == N) {
		/*for (int i = cap; i >= 0; i--) {
			ans += num;
			num *= 2;
		}*/
		ans += num*log_num[cap] * 2 - num;
		fig+=cap+1;
	}
	return ;
}

int main() {
	cin >> N;
	search(0, 0,31);
	cout << fig << " " << ans << "\n";
	return 0;
}
0